runtime: Better diagnostic for native .dll loading errors (pass through dlerror)
Hi I am trying to write a .NET Core wrapper for the LLVM C Frontend. However I am having trouble with the runtime finding the dylib.
Failed LLVMWrap.Tests.BasicTests.TestBasicSumMethod
Error Message:
System.DllNotFoundException : Unable to load DLL 'libLLVM.dylib': The specified module could not be found.
(Exception from HRESULT: 0x8007007E)
Stack Trace:
at LLVMWrap.LLVMAPI.LLVMInt32Type()
at LLVMWrap.Core.Types.LLVMInt32Type..ctor() in /Users/alexander/github/LLVMWrap/LLVMWrapCore/Core/Types/LLVMInt32Type.cs:line 11
at LLVMWrap.Core.Types.LLVMInt32Type.<>c.<.cctor>b__4_0() in /Users/alexander/github/LLVMWrap/LLVMWrapCore/Core/Types/LLVMInt32Type.cs:line 7
at System.Lazy`1.CreateValue()
at System.Lazy`1.LazyInitValue()
at LLVMWrap.Core.Types.LLVMInt32Type.get_Instance() in /Users/alexander/github/LLVMWrap/LLVMWrapCore/Core/Types/LLVMInt32Type.cs:line 14
at LLVMWrap.Tests.BasicTests.TestBasicSumMethod() in /Users/alexander/github/LLVMWrap/LLVMWrap.Tests/BasicTests.cs:line 15
I’ve tried the project paths, the bin/debug/target/ path and nothing. Any clues about what I might be missing? or is this a bug?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 29 (25 by maintainers)
We encountered
When running a program on a newly mounted disk. The application worked fine on the main disk, but it would fail as above when the application was copied to the mounted disk.
Using
strace
, gave insight into why the assembly couldn’t be loaded:From reading the ‘man mmap’ pages:
Which was the problem - the disk was mounted no-exec. Remounting it with the exec option allowed the application to start running again.
Better diagnostics info in the exception would have helped speed up this investigation and narrow the problem sooner.
I think I have suggested a long time ago to change the error message to “The specified module or one of its dependencies could not be found.” That way it would hint the user to verify that the reported .dylib / .so has all the dependencies it needs. On Linux, “ldd -r” is the best way. On OSX, the “otool -L” command should work. @alexanderuv would it have helped you to pinpoint the issue if the message was modified like I’ve said?