Error logging on Windows

Started by Forestidia86, April 26, 2024, 09:49:54 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Forestidia86

Due to issue #488 some errors aren't logged into log.txt, although the error would show on console/shell.

On Win the console is suppressed, so that it can happen that no error feedback is given (in case no error window appears). As a workaround piping with e.g. lix.exe 2>a.txt produces the error message in a.txt.

Simon

Right.

First, #488: Logging (user/log.txt): Exceptions during init aren't logged. This will be easy to fix. I'll fix this in the next release, Lix 0.10.23. I've already put the fix in my unstable repo's master.

Second, on Windows, years ago, the D runtime used to generate a dialog box for unrecoverable errors (exceptions/errors flying out of main). Only after clicking away that dialog box, Lix would exit. Nowadays, we don't get this dialog box anymore. I don't know why we don't get the dialog anymore.

Third, on Windows, we suppress the console. This is correct. We'll ask people to look in user/log.txt for errors. The above #488 has prevented this during initialization, it won't prevent it from Lix 0.10.23 on.




We can investigate why there is no dialog box (above "Second, on Windows ..."). Possible relation with suppressing the console? Although we have suppressed the console for years, too.

-- Simon

Simon

#2
We link both the 32-bit and the 64-bit executables with lld-link. These executables will try to write all exceptions flying out of main() to stderr, which is closed because we suppress the console. Therefore, we see Lix terminate seemingly without error.

When we link a test project with Optlink (instead of with lld-link) and again suppress the console, we get the desired error box for exceptions flying out of main().

Is it possible to route the uncaught exceptions to error boxes even when we link with lld-link? I've looked through lld-link's command-line switches, and none of them look related. I'll ask on the D forums these days.

-- Simon

Simon

#3
I'm asking on the D forums: Does the D runtime support generating an error box for uncaught exceptions?

I don't believe it does. We'll generate the message box by hand.

version (Windows) {
    import core.sys.windows.windows;
    const wstring messageBody = /* ... */
    MessageBoxW(null, messageBody.ptr, null, MB_ICONERROR);
}


I'll put this in the catch-all that logs uncaught exceptions, then terminates Lix. Now, every time we log an uncaught exception on Windows, we'll also display an error box.

The box doesn't know about the Allegro 5 window (= Lix's main window). You can bring the hanging Lix window into the foreground, obscuring the modal box. Possible future investigation: Pass the Allegro 5 window instead of null for the first argument to MessageBoxW() and look at how the box interacts with the Lix window.

-- Simon

Simon

We produce boxes for the out-of-VRAM error.

In Lix 0.10.27, we don't produce a box for missing resource files (when we run the Lix executable outside the Lix worktree). We want a box here, at least in interactive mode. Investigate.

Unsure what I want in noninteractive mode (replay verification from the command line) when you lack resource files.

-- Simon

Simon

#5
Earmarked for 0.10.28: We'll generate the message box in interactive mode even for the missing resources. We won't log the error when we don't find our worktree, but we still show the box.

We won't show boxes in noninteractive mode. On Windows, redirect stderr to a file to see errors in noninteractive mode:
lix.exe 2> err.txt

-- Simon