RE: [mpatrol] Re: Problems running mpatrol in MinGW
- Hi Greg,Sorry I've taken so long to get back to you. I'm not a MinGW user but there are several people in this group that have reported success using mpatrol with MinGW. Does anyone have any thoughts on getting mpatrol to work for Greg in his setup?There appears to be an issue with mpatrol.dll when it's built to use msvcrt.dll so perhaps building everything against Microsoft's libc might work, but I don't know if that's an option with MinGW and would require you to have Visual Studio already installed on your machine.mpatrol was developed for UNIX systems and it looks like it might need to have a bit more work done to it to get it to work consistently under Windows in all setups. In particular, I'd like to have mpatrol --dynamic work, but that needs quite a bit of work to use DLL injection. I'm afraid all this could mean that it's just not going to work for you at the moment.Sorry I can't be of more help,Graeme.From: firstname.lastname@example.org [mailto:email@example.com] On Behalf Of greg80303
Sent: 09 March 2009 03:32
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/ fail.
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 .com, "greg80303" <grutz@...> wrote:
> Windows XP SP3 /
>myself. I simply went into <mpatrol>/build/ windows and executed "make -f Makefile.mingw all", then copied the include files to my include directory and the mpatrolmt.dll file to the same directory as my executable.
> I have downloaded the 1.5.1 SVN tag tree and built it
>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/ GetProcAddress) to start the rest of the system. So, the launcher itself is not linked against any external DLLs from our system.
> I am trying to use mpatrol to do some memory analysis on a piece of
>-Ic:/<myproject> /include -include mpatrol.h -I./Win32 main.c -o c:/<myproject> /gen/Win32/ debug/launcher/ main.o
> The compile line for my launcher looks something like this:
> gcc -c -mno-cygwin -g -DRI_HAVE_STDINT_ H -Wall
>-Ic:/<myproject> /include -include mpatrol.h -I./Win32 -Ic:/<myproject> /include Win32/port.c -o c:/<myproject> /gen/Win32/ debug/launcher/ ./Win32/port. o
> gcc -c -mno-cygwin -g -DRI_HAVE_STDINT_ H -Wall
>c:/<myproject> /install/ Win32/debug/ bin/ri.exe c:/<myproject> /gen/Win32/ debug/launcher/ main.o c:/<myproject> /gen/Win32/ debug/launcher/ ./Win32/port. o -Lc:/<myproject> /install/ Win32/debug/ bin -lmpatrolmt
> g++ -mno-cygwin -o
>in GDB, I get the following SIGSEGV notification:
> The program crashes before ever getting to my main(). Running
> Starting program:c:/<myproject> /install/ Win32/debug/ bin/ri.exe c:/<myproject> /launcher/ launcher_ win32.cfg
> [Newthread 656.0xaac]
> Program received signal SIGSEGV, Segmentation
> 0x7c9104da in ntdll!RtlStatMemory Stream () fromC:\WINDOWS\system32 \ntdll.dll
> (gdb)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( ) to see if I could learn anything.
>program: c:/<myproject> /install/ Win32/debug/ bin/ri.exe c:/<myproject> /src/launcher/ launcher_ win32.cfg
> (gdb) run
>[New thread 1108.0xd7c]
> Breakpoint 1, __mp_printversion () at
> (gdb) whereat ../../src/diag. c:1805
> #0 __mp_printversion ()
> #1 0x004d575f in __mp_init () at../../src/inter. c:508
> #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. c:873
> #3 0x004da8d1 in malloc (l=128) at../../src/malloc. c:55
> #4 0x004c10c3 in DllMainCRTStartup@ 12 ()from c:\<myproject> \install\ Win32\debug\ bin\mpatrolmt. dll
>#5 0x7c90118a in ntdll!LdrSetAppComp atDllRedirection Callback () from C:\WINDOWS\system32 \ntdll.dll
> #6 0x004c0000 in ?? ()0x00000001 in ?? ()
> #8 0x0022fd30 in ?? ()__dll_exit () from c:\<myproject> \install\ Win32\debug\ bin\mpatrolmt. dll
> #9 0x004c1060 in
>#10 0x7c91c4da in ntdll!LdrHotPatchRo utine () from C:\WINDOWS\system32 \ntdll.dll
> #11 0x7c921194 inntdll!RtlMapGeneric Mask () from C:\WINDOWS\system32 \ntdll.dll
>#12 0x7c92108f in ntdll!RtlMapGeneric Mask () from C:\WINDOWS\system32 \ntdll.dll
> #13 0x7c90e437 inntdll!LdrCreateOutO fProcessImage () from C:\WINDOWS\system32 \ntdll.dll
>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?
> I can step all the way