Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: if Digest::SHA1 loaded Can't load LibXML/LibXML.dll Invalid access to memory location

by bulk88 (Priest)
on Dec 03, 2012 at 02:32 UTC ( #1006775=note: print w/ replies, xml ) Need Help??


in reply to if Digest::SHA1 loaded Can't load LibXML/LibXML.dll Invalid access to memory location

"load_file:Invalid access to memory location" means one and only one thing, in the XS DLL, or any dependency DLL which has not been loaded before (kernel32, advapi32, perl51*.dll for example were already loaded so they can not be the cause), a DllMain of the new in the process DLL, had a SEGV/access violation, when it was called from LoadLibrary/Dynaloader. Windows instead of crashing the process, traps the access vio and returns FALSE to the caller (Dynaloader) of LoadLibrary and sets Win32 LastError correct and that is what you see here.

Try http://www.dependencywalker.com/, IDK if it will help you identify which particular DLL crashed or not the tree of dependencies. The other choice is a C debugger which will ideally answer the problem in a few seconds.

Win32 specific XS modules rarely define a DllMain, and portable XS modules never will, but all DLLs have a DllMain placed by the C compiler, usually to initialize various clib/crt features or hook OS thread creation for TLS reasons.


Comment on Re: if Digest::SHA1 loaded Can't load LibXML/LibXML.dll Invalid access to memory location
Re^2: if Digest::SHA1 loaded Can't load LibXML/LibXML.dll Invalid access to memory location
by Anonymous Monk on Dec 03, 2012 at 09:54 UTC

    You don't say :/ that isn't exactly new to me :)

    dependencywalker won't try to load two dlls at once, so I can't trigger this error using that tool

    Usually, I'll get a drwtsn32 popup, which'll tell me which dll the memory access violation happened upon (not just the perl/xs dll)

    I have WinDbg , but there is nothing extra there if I attach (F6) to   perl.exe -e " require Digest::SHA1; scalar <>; require XML::LibXML; " and Go (F5) or "Go Handled Exception" from Debug menu

    ModLoad: 00ca0000 00f84000 ....auto\XML\LibXML\LibXML.dll (8e8.aec): Access violation - code c0000005 (first chance) First chance exceptions are reported before any exception handling. This exception may be expected and handled. eax=0022ed8c ebx=00ca1420 ecx=00009599 edx=00000001 esi=0022ed14 edi=0 +0000001 eip=00ca1427 esp=0022ece8 ebp=0022ed20 iopl=0 nv up ei pl nz a +c pe nc cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=0 +0010216

    I recognize c0000005 but I don't see a faulting module and fault addressss

    I get this on two different perl versions (v5.14.1 , v5.16.1 ) , with two different gcc

    gcc version 4.6.3 (gcc-4.6.3 release with patches [build 20121012 by p +erlmingw.sf.net]) gcc version 4.7.0 (GCC) (mingw.org)

    Any other ideas I can try?

      Dependency walker can "profile" a process, menubar->profile->start profiling, it will log every DLL static and dynamic linked during the whole run life of the process.

      Since I assume you are using Mingw, you need to compile the XS module without "-s" so it has debugging info then use the gdb infrastructure so you have symbols and can see the original C code and original var names. I can't give any specifics to WinDbg since its UI is much more difficult than VS Debugger. You probably have to goto disassembly window in WinDbg, see the current instruction address, or use register EIP in the dump above. Then figure out which mapped into address space DLL that EIP falls into. You can use http://virtualmemorymapview.codeplex.com/releases/view/28113 or MS's VMMap to see where the DLLs are in that processes memory.

        Dependency walker can "profile" a process, menubar->profile->start profiling, it will log every DLL static and dynamic linked during the whole run life of the process.

        I don't see any "profile" option

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1006775]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2014-07-29 00:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (211 votes), past polls