Sent: 09 March 2009 03:32
To: mpatrol@yahoogroups.com
Subject: [mpatrol] Re: Problems running mpatrol in MinGW
Thought I would add a couple more observations that I've made regarding the use of DLLs vs static libs. I played around a little with compiling and running the test applications in mpatrol/tests/
1) If I compile and link the test application against the static mpatrol library, all works as expected.
2) If I compile and link the test application against the mpatrol DLL, I get a crash when I run.
3) If I compile my executable against the static mpatrol library, all works as expected.
4) If I compile my executable against the mpatrol DLL, I get a crash when I run. This is the exact situation of my original post.
5) I compile my executable against the static mpatrol library. But, this time, my application contains calls against another DLL (call it "myappDLL"), so I link my application against myappDLL. Regardless of whether myappDLL is compiled against mpatrol static lib or mpatrol DLL, I get a crash.
6) Same as #5, but this time I do not compile myappDLL against mpatrol. All works as expected (but I want to have all of my app DLLs using mpatrol, so this doesn't help me)
7) Same as #5, but instead of compiling my executable against myappDLL, I use LoadLibrary and GetProcAddress to call into myappDLL. Regardless of whether myappDLL is compiled against static or DLL version of mpatrol, I get a crash upon call to LoadLibrary.
I've read Greg Chicares' investigation documents posted in the files section of this group, but I don't see anything in his work about crashes, only errors and corruption in the log file.
--- In mpatrol@yahoogroups
>
> Windows XP SP3 / MinGW
>
> I have downloaded the 1.5.1 SVN tag tree and built it myself. I simply went into <mpatrol>/build/
>
> I am trying to use mpatrol to do some memory analysis on a piece of software. The complete system is pretty complex, but I am starting with only a small piece. Our "launcher" is a simple executable that does some reading of configuration files and then calls DLL entry points (via LoadLibrary/
>
> The compile line for my launcher looks something like this:
>
> gcc -c -mno-cygwin -g -DRI_HAVE_STDINT_
>
> gcc -c -mno-cygwin -g -DRI_HAVE_STDINT_
>
> g++ -mno-cygwin -o c:/<myproject>
>
> The program crashes before ever getting to my main(). Running in GDB, I get the following SIGSEGV notification:
>
> (gdb) run
> Starting program: c:/<myproject>
> [New thread 656.0xaac]
>
> Program received signal SIGSEGV, Segmentation fault.
> 0x7c9104da in ntdll!RtlStatMemory
> (gdb)
>
> The mpatrol.log file is created and there is some information in it. So, I rebuilt mpatrol with debug symbols and put a breakpoint in __mp_printversion(
>
> (gdb) run
> Starting program: c:/<myproject>
> [New thread 1108.0xd7c]
>
> Breakpoint 1, __mp_printversion () at ../../src/diag.
> (gdb) where
> #0 __mp_printversion () at ../../src/diag.
> #1 0x004d575f in __mp_init () at ../../src/inter.
> #2 0x004d5f8a in __mp_alloc (l=128, a=0, f=AT_MALLOC, s=0x0, t=0x0, u=0, g=0x0, h=0, k=1) at ../../src/inter.
> #3 0x004da8d1 in malloc (l=128) at ../../src/malloc.
> #4 0x004c10c3 in DllMainCRTStartup@
> #5 0x7c90118a in ntdll!LdrSetAppComp
> #6 0x004c0000 in ?? ()
> #7 0x00000001 in ?? ()
> #8 0x0022fd30 in ?? ()
> #9 0x004c1060 in __dll_exit () from c:\<myproject>
> #10 0x7c91c4da in ntdll!LdrHotPatchRo
> #11 0x7c921194 in ntdll!RtlMapGeneric
> #12 0x7c92108f in ntdll!RtlMapGeneric
> #13 0x7c90e437 in ntdll!LdrCreateOutO
>
> I can step all the way through until I am back in the DllMainCRTStartup function. Then, the next step causes the crash. Any ideas for me? Any more information I could provide to help?
>
> Greg
>