Ticket #18 (assigned enhancement)

Opened 2 months ago

Last modified 2 months ago

util.loader error message

Reported by: Cyborg16 Assigned to: aldacron (accepted)
Priority: minor Version:
Keywords: Cc:

Description

Here's a slight change to util/loader.d to improve error messages when loading shared libraries fails (on unix):

Change line 204 to:

            throw new SharedLibLoadException(libName ~ "; reason: " ~ toDString(dlerror()));

It ends up with a longer error message, but without this there's no way to know why a shared library failed to load. Example:

Failed to load shared library libSDL-1.2.so.0; reason: libx86.so.1: cannot open shared object file: No such file or directory

Change History

04/21/08 17:13:18 changed by Cyborg16

Of course, it's still the case that only one error message actually gets reported, in the case that all libnames fail to load a library... the only other solution I can think of would be to keep a list of all error messages as they are caught by SharedLib? Derelict_LoadSharedLib(char[][] libNames) and if no library gets loaded print them all (or concatenate the errors, e.g. with '\n' as a separator and throw a new exception with this message).

04/22/08 06:18:14 changed by Cyborg16

I figured the easiest way to keep previous exceptions would be to use Exception's next property (Tango only); from line 113 in loader.d:

        catch(SharedLibLoadException slle)
        {
            version (Tango) {   // don't drop previous exception messages.
                slle.next = exception;
            }
            exception = slle;
        }

This does put the exceptions in reverse order, but at any rate allows all messages to be printed easily. I was rather surprised by the result − the same message 4 times! I need to check this... (and get SDL to work again!):

Fatal mde.scheduler.Init.Init - Failed to load shared library libSDL-1.2.so.0; reason: libx86.so.1: cannot open shared object file: No such file or directory
Fatal mde.scheduler.Init.Init - Failed to load shared library libSDL-1.2.so.0; reason: libx86.so.1: cannot open shared object file: No such file or directory
Fatal mde.scheduler.Init.Init - Failed to load shared library libSDL-1.2.so.0; reason: libx86.so.1: cannot open shared object file: No such file or directory
Fatal mde.scheduler.Init.Init - Failed to load shared library libSDL-1.2.so.0; reason: libx86.so.1: cannot open shared object file: No such file or directory

04/22/08 06:31:00 changed by Cyborg16

  • priority changed from major to minor.

I confirmed the identical messages are just to do with the exception messages; not really sure why. But debug messages confirm it does actually try all lib names (and the exception messages are different at the time they're caught).

So the change in the opening ticket is useful, the second change above isn't.

My issue with SDL is off-topic; I'll post else-where if necessary.

05/21/08 06:54:32 changed by aldacron

  • owner set to aldacron.
  • status changed from new to assigned.

I'll look into this. At the very least, I'll queue up all of the attempted library names to report them. But for consistency, I feel compelled to implement error message handling on Windows if we're going to be reporting dlerror on Unices.