Comments (19)
FWIW, the following code (invoked before the first code of ClrMD is called) helped me with the issue:
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
private static extern IntPtr LoadLibraryEx(string lpFileName, IntPtr hReservedNull, int dwFlags);
private const int LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR = 0x00000100;
private static void EnsureProperDebugEngineIsLoaded()
{
var sysdir = Environment.GetFolderPath(Environment.SpecialFolder.System);
var res = LoadLibraryEx(Path.Combine(sysdir, "dbgeng.dll"), IntPtr.Zero, LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR);
if (res == IntPtr.Zero)
throw new Win32Exception(Marshal.GetLastWin32Error());
}
Essentially, when called before ClrMD's DllImport of dbgeng.dll has a chance to run, it not only loads dbgeng.dll from the Windows system directory, but also force it to look for its dependencies only there.
That should prevent such dependencies to be loaded from other folders.
from clrmd.
Hmm. That's an interesting one. Does it fail 100% of the time on those machines, or does it happen intermittently?
dngeng.dll is a windows component, it should be located on every machine in "C:\Windows\System32\dbgeng.dll". For the machines this does not work on, can you check to see that this file exists and isn't corrupted? (Hard to check the latter but at least make sure the file isn't of 0 length.)
If the file exists I would suggest trying two things:
- Build ClrMD from source yourself (maybe use the v0.8.31.0 tag) and remove the
DefaultDllSearchPaths
attribute: https://github.com/Microsoft/clrmd/blob/v0.8.31.0/src/Microsoft.Diagnostics.Runtime/Desktop/helpers.cs#L364 Then see if the problem still reproduces. If the issue is fixed by removing this line, please let me know. That means there's an issue with that attribute and something I need to fix. - If that does not fix the issue then I'm not sure what the problem is. You can try to load dbgeng.dll yourself into the process as the first thing in your main method. To do that add a PInvoke to
LoadLibrary
and callLoadLibrary(@"c:\windows\system32\dbgeng.dll")
(you should use the system directory instead of hard coding C:\windows, but you get the idea).
Please let me know what you find. It's really tough for me to know what the problem is without being able to reproduce the issue myself, but if you have some time to do the above investigation I'll try to get this taken care of asap.
Thanks for the bug report!
from clrmd.
Thanks for quick reply. Here are my findings:
- It fails 100% of times when ran from RavenDB on those machines and 0% of times when run manually from CMD or console application (strange?)
- The DLL exists in C:\Windows\System32
- After removing the DefaultDllSearchPaths it still fails
- LoadLibrary returns success
Maybe the problem is not that DLL cannot be found but 'The specified procedure could not be found'?
from clrmd.
It looks like a path lacking in the account running RavenDB. Is there a profile created for such account? It can also be lack of rights in RavenDB account.
Try procmon to verify dll loading errors.
Sent from my Windows Phone
From: Paweł Pekrólmailto:[email protected]
Sent: 10/27/2015 2:42 AM
To: Microsoft/clrmdmailto:[email protected]
Subject: Re: [clrmd] System.DllNotFoundException (#29)
Thanks for quick reply. Here are my findings:
- It fails 100% of times when ran from RavenDB on those machines and 0% of times when run manually from CMD or console application (strange?)
- The DLL exists in C:\Windows\System32
- After removing the DefaultDllSearchPaths it still fails
- LoadLibrary returns success
Maybe the problem is not that DLL cannot be found but 'The specified procedure could not be found'?
Reply to this email directly or view it on GitHub:
#29 (comment)
from clrmd.
I do not see anything out of order in procmon (screen: http://1drv.ms/1GFDLb1) and the account I'm using have Administrative privileges (Win 10 x64 Pro).
from clrmd.
@ppekrol What happens if you try to do a File.Read on tha tpath
from clrmd.
I've read the dbgeng.dll without any problems using Raven.Debug
using (var stream = File.OpenRead(@"C:\Windows\System32\dbgeng.dll"))
using (var reader = new StreamReader(stream))
{
var dll = reader.ReadToEnd();
}
from clrmd.
One last thing to try. Can you successfully run this program on the machines where this is failing?
https://gist.github.com/leculver/b48d6c7eb5a99f94af5a
from clrmd.
Here are my findings from running your code:
I. Running from CMD
- Compiled as x64: works
- Compiled as x86: works
II. Spawning process from RavenDB WebAPI controller (Environment.Is64BitProcess returns true)
- Spawning x64 compiled code: error (see below)
- Spawning x86 compiled code: works
Error is:
"The procedure entry point SetSymLoadError could not be located in the dynamic link library C:\Windows\system32\dbgeng.dll"
line that throws:
IntPtr debugCreate = GetProcAddress(dbgeng, "DebugCreate");
from clrmd.
@ppekrol
It probably has nothing to do with the issue, but why are you setting LoadUserProfile = true
when you spawn the sub process?
I would also be curious to see if it works when you set UseShellExecute = true
.
from clrmd.
No good reason I guess for setting LoadUserProfile to true, will remove it, thanks!
Checked with UseShellExecute = true with same results, still fails.
from clrmd.
I have asked a few experts around here. They said dbgcore.dll needs to be in the folder/search path. Can you check to see if that file exists in your search path? (c:\windows\system32). I don't know why it wouldn't be though...
You could probably check by calling LoadLibrary("dbgcore.dll") in the test program and checking the return value against IntPtr.Zero.
from clrmd.
It is there, next to dbgeng.dll. This is really strange, because when I run this program from CMD then it all works. It just doesn't when I spawn process from WebAPI controller.
LoadLibrary("dbgcore.dll") loads correctly.
Can I assume that this message
"The procedure entry point SetSymLoadError could not be located in the dynamic link library
C:\Windows\system32\dbgeng.dll"
means that the dbgeng.dll exists and is loaded correctly, but SetSymLoadError is not there (for unknown reason)?
Do you have an idea why it is not working when I compile program as x64?
from clrmd.
Maybe it is a compact shim?
On Oct 29, 2015 09:00, "Paweł Pekról" [email protected] wrote:
It is there, next to dbgeng.dll. This is really strange, because when I
run this program from CMD then it all works. It just doesn't when I spawn
process from WebAPI controller.LoadLibrary("dbgcore.dll") loads correctly.
Can I assume that this message
"The procedure entry point SetSymLoadError could not be located in the dynamic link library
C:\Windows\system32\dbgeng.dll"means that the dbgeng.dll exists and is loaded correctly, but
SetSymLoadError is not there (for unknown reason)?Do you have an idea why it is not working when I compile program as x64?
—
Reply to this email directly or view it on GitHub
#29 (comment).
from clrmd.
I found some references that says SetSymLoadError is located in dbghelp.dll. Maybe your WebAPI host exe in x64 has a PATH which include a wrong version of dbghelp.dll. You could validate this by spawning cmd.exe
with args where dbghelp.dll
in the WebAPI process.
from clrmd.
On my machine, I get this error:
The procedure entry point SetCheckUserInterruptShared could not be located in the dynamic link library C:\windows\SYSTEM32\dbgeng.dll.
There is a similar error here VerySleepy/verysleepy#7 (comment)
With the core of the issue:
we load the system dbgeng, which then tries to load dbghelp, but instead of loading the system one, it's loading Sleepy's version, which is too old for the system dbgeng
And that probably explains it. Are we (either ravendb or clrmd) packaging dbghelp?
This error would only occur on specific versions of debugging tools for windows, I'm guessing.
from clrmd.
Haven't heard back on this one in a while, but it sounds like ayende's analysis is correct here. Please feel free to reply here if this is still an issue for you.
from clrmd.
Not sure if it's the same thing, but I also encountered the dbgeng exception, also on a machine running .NET 4.6.1.
In my case, the solution was to remove the "prefer 32-bit" flag in the project's build settings. Once it ran as a 64-bit console app, it managed to load the dll.
from clrmd.
@cklutz, thank you very much! I've encountered the same situation as @ppekrol (debugger runs successfully from CMD, but fails when launched from the debuggee process). @cklutz's solution solved the problem completely.
from clrmd.
Related Issues (20)
- ClrMD should stop using HResult as a PInvoke return HOT 4
- [macOS] task_for_pid failing with `0x5` HOT 6
- HotColdInfo.HotSize is missing in v2 (it's present in v1) HOT 1
- CLRMD fails to load coreclr 7.0 dump - PEImage.Read() doesn't update offset HOT 1
- CLRMD fails to load coreclr 7.0 dump - PEImage.Read() does not apply fixups HOT 3
- Disparity in Objects... HOT 1
- COMException in CacheNativeMethods.Util.EnableDisablePrivilege HOT 2
- Links on FAQ page broken...
- Getting IL and Native Code Addresses... HOT 3
- Windows arm64 support HOT 5
- The license disorientation HOT 1
- ClrMD is moving to dotnet/diagnostics HOT 1
- ClrMD 3.0 will be the next release
- Get ClrValueType similar to !DumpVC HOT 3
- This repo is missing important files
- Could not find matching DAC for process on macOS after switching to ClrMD 2.1
- ILOffsetMap points to QuickJitted assembly code even after method has been Tier-1 compiled (.NET 7+) HOT 1
- Where are the release notes for ClrMD 3.0 ? HOT 3
- Threads are not update after flush HOT 3
- Unable to create DACLibrary for minidump from self contained app HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clrmd.