public inbox for pthreads-win32@sourceware.org
 help / color / mirror / Atom feed
* working release test failed in debug mode
       [not found] <58344da04430a2f0b57d52a9e514b98d.squirrel@mmp.sipr-dc.ucl.ac.be>
@ 2009-06-12 13:00 ` Diego Ruiz
  2009-06-12 16:09   ` Geoff McLane
  0 siblings, 1 reply; 2+ messages in thread
From: Diego Ruiz @ 2009-06-12 13:00 UTC (permalink / raw)
  To: pthreads-win32


Hello,

I manage to test a very small example in release mode. However the same
example crashes in debug mode.

Thanks for any help or idea
Diego

Ps: I am new to windows. I need to port my application from ubuntu to
visual studio.


Microsoft Visual Studio 2005
New project -> WIN32 -> WIN32 Console application (name Hello)

•	Added #include <pthread.h> to stdafx.h
•	Changed Hello.cpp:
#include "stdafx.h"

 pthread_mutex_t mutex_bigbag   = PTHREAD_MUTEX_INITIALIZER;

/*! This program test compilation with the pthread library on windows */
int _tmain(int argc, _TCHAR* argv[])
{

    printf("hello\n");
    getchar();
    getchar();

    pthread_mutex_lock( &mutex_bigbag );

    pthread_mutex_unlock(&mutex_bigbag);

    return 0;
}

•	QueueUserAPCEx:
- Copy the driver and reboot as explained in the README file of directory
- Copying the dll  (QuserEx.dll, QuserEx.lib) in working directory of
solution (release, debug)
- Copying the lib in an usefull_libs directory
- using "net start alertdrv" in command prompt (cmd) in administrator mode

•	pthreads.2:
- programs-> Visual studio -> visual studio tools -> VS command prompt
- cd directory of pthreads.2
- nmake clean VCE-inlined
- copy the created dll in working directory of solution (release, debug)
- copy of the library in usefull_libs directory

•	Test 1 in realease mode
- Added path to inlcludes (pthread.h)
- Added path to library in linker (usefull_libs)
- Added library dependency in linker (pthreadVCE2.lib quserex.lib)
- Compilation OK (0 errors, 0 warnings)
- Test OK (prints hello and wait for char in terminal)

•	Test in debug mode

- Added path to inlcludes (pthread.h)
- Added path to library in linker (usefull_libs)
- Added library dependency in linker (pthreadVCE2.lib quserex.lib)
- Compilation OK (0 errors, 0 warnings)
- Test KO:

'Hello.exe': Loaded 'C:\Users\ruiz\Documents\Visual Studio
2005\Projects\Tests\Hello\debug\Hello.exe', Symbols loaded.
'Hello.exe': Loaded 'C:\WINDOWS\System32\ntdll.dll', No symbols loaded.
'Hello.exe': Loaded 'C:\WINDOWS\System32\kernel32.dll', No symbols loaded.
'Hello.exe': Loaded 'C:\Users\ruiz\Documents\Visual Studio
2005\Projects\Tests\Hello\debug\pthreadVCE2.dll', Symbols loaded.
'Hello.exe': Loaded 'C:\Users\ruiz\Documents\Visual Studio
2005\Projects\Tests\Hello\debug\msvcr80.dll', No symbols loaded.
'Hello.exe': Loaded 'C:\WINDOWS\System32\msvcrt.dll', No symbols loaded.
'Hello.exe': Loaded 'C:\WINDOWS\System32\wsock32.dll', No symbols loaded.
'Hello.exe': Loaded 'C:\WINDOWS\System32\ws2_32.dll', No symbols loaded.
'Hello.exe': Loaded 'C:\WINDOWS\System32\advapi32.dll', No symbols loaded.
'Hello.exe': Loaded 'C:\WINDOWS\System32\rpcrt4.dll', No symbols loaded.
'Hello.exe': Loaded 'C:\WINDOWS\System32\nsi.dll', No symbols loaded.
'Hello.exe': Loaded
'C:\WINDOWS\winsxs\x86_microsoft.vc80.debugcrt_1fc8b3b9a1e18e3b_8.0.50727.762_none_24c8a196583ff03b\msvcr80d.dll',
Symbols loaded.
'Hello.exe': Loaded 'C:\WINDOWS\System32\user32.dll', No symbols loaded.
'Hello.exe': Loaded 'C:\WINDOWS\System32\gdi32.dll', No symbols loaded.
'Hello.exe': Loaded 'C:\WINDOWS\System32\imm32.dll', No symbols loaded.
'Hello.exe': Loaded 'C:\WINDOWS\System32\msctf.dll', No symbols loaded.
'Hello.exe': Loaded 'C:\WINDOWS\System32\lpk.dll', No symbols loaded.
'Hello.exe': Loaded 'C:\WINDOWS\System32\usp10.dll', No symbols loaded.
'Hello.exe': Loaded 'C:\WINDOWS\System32\APSHook.dll', Binary was not
built with debug information.
First-chance exception at 0x77943387 in Hello.exe: 0xC0000005: Access
violation writing location 0x00000014.
R6034
An application has made an attempt to load the C runtime library incorrectly.
Please contact the application's support team for more information.
Windows has triggered a breakpoint in Hello.exe.

This may be due to a corruption of the heap, and indicates a bug in
Hello.exe or any of the DLLs it has loaded.

The output window may have more diagnostic information
First-chance exception at 0x77909cac in Hello.exe: 0xC0000142: DLL
Initialization Failed.
Unhandled exception at 0x77909cac in Hello.exe: 0xC0000142: DLL
Initialization Failed.
Hello.exe has triggered a breakpoint
First-chance exception at 0x769e8f21 in Hello.exe: 0xC0000005: Access
violation reading location 0x769e8f21.


 *** A stack buffer overrun occurred in "c:\users\ruiz\documents\visual
studio 2005\projects\tests\hello\debug\Hello.exe" :

This is usually the result of a memory copy to a local buffer or structure
where the size is not properly calculated/checked.
If this bug ends up in the shipping product, it could be a severe security
hole.
The stack trace should show the guilty function (the function directly
above __report_gsfailure).
 *** enter .exr 779C9320 for the exception record
 *** then kb to get the faulting stack

Windows has triggered a breakpoint in Hello.exe.

This may be due to a corruption of the heap, and indicates a bug in
Hello.exe or any of the DLLs it has loaded.

The output window may have more diagnostic information
Windows has triggered a breakpoint in Hello.exe.

This may be due to a corruption of the heap, and indicates a bug in
Hello.exe or any of the DLLs it has loaded.

The output window may have more diagnostic information
The program '[5584] Hello.exe: Native' has exited with code -1073740791
(0xc0000409).







^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: working release test failed in debug mode
  2009-06-12 13:00 ` working release test failed in debug mode Diego Ruiz
@ 2009-06-12 16:09   ` Geoff McLane
  0 siblings, 0 replies; 2+ messages in thread
From: Geoff McLane @ 2009-06-12 16:09 UTC (permalink / raw)
  To: Diego Ruiz; +Cc: pthreads-win32

Hi Diego,

>> any help or idea

Not sure if any of this will help, but...

(a) It is 'normal' that sometimes 'Release'
will appear to run, while 'Debug' crashes.

There are MORE runtime checks done in 'Debug',
mode, that will sometime pass in 'Release' mode,
but that does NOT mean the problem is not
present in BOTH!

(b) This may NOT be a pthread DLL problem at
all! It may be in QuserEx.dll!! or APSHook.dll...
or others loaded...

(c) The error you showed, R6034, is an attempt
to load a DLL without using a manifest. Check out
this error number in the MSVC8 HELP.

For example, certainly, the steps you showed
to build the pthread DLL/LIB, did NOT appear
to include running the 'mt' manifest tool -
- nmake clean VCE-inlined

You need to check that the 'Makefile'
DOES include embedding the manifest
inside the DLL.. that is runs the 'mt'
tool with a resource ID 2. Again see the
HELP information for details...

Some 'older' Makefiles MISSED this step,
only required after circa 2003!

This manifest embedding would have been 
automatically done by MSVC8 (2005) when you 
build the 'Hello' application, using the
MSVC8 IDE, but manifest MUST also be 
embedded in ALL the DLL's loaded
as well...

This would include the QuserEx.dll, and
the APSHook.dll, the last being loaded before
the runtime error...

(d) I built your 'hello' applications, and
had no such problem, but I DID NOT include
'quserex.lib' in the link... maybe try 
excluding this, to narrow down the problem...

There is nothing shown in your 'test'
application, as shown, that requires this DLL!

(e) Some other difference noted when I ran my
debug 'Hello.exe' in MSVC8 to what you 
showed in your email -

(i) Mine only loaded -
C:\WINDOWS\system32\ws2_32.dll
but I note your output _ALSO_ included
C:\WINDOWS\system32\wsock32.dll

You should only have ONE or the OTHER of
these loaded... ws2 is just version 2
of the windows sockets DLL, and with it,
the older version 1 should not need to be
loaded...

(ii) Yours loaded BOTH -
'Hello.exe': Loaded 'C:\Users\ruiz\Documents\Visual Studio
2005\Projects\Tests\Hello\debug\msvcr80.dll'
 +AND+
'C:\WINDOWS\winsxs
\x86_microsoft.vc80.debugcrt_1fc8b3b9a1e18e3b_8.0.50727.762_none_24c8a196583ff03b\msvcr80d.dll'
while mine ONLY loaded the WinSXS version msvcr80d.dll,
as it should be!

You should perhaps delete the Tests\Hello\debug\msvcr80.dll!
This MS runtime DLL, or other MS DLLS should NOT 
be copied to your 'work' folders...

If you feel for some reason you have to, to
get it running, then this again suggests
some problem with the 'mt' tool, or some
other problem???

(iii) Yours loaded a whole bunch of other DLL 
that are NOT present in my load, like -
'Hello.exe': Loaded 'C:\WINDOWS\System32\rpcrt4.dll', No symbols loaded.
'Hello.exe': Loaded 'C:\WINDOWS\System32\nsi.dll', No symbols loaded.
'Hello.exe': Loaded 'C:\WINDOWS\System32\user32.dll', No symbols loaded.
'Hello.exe': Loaded 'C:\WINDOWS\System32\gdi32.dll', No symbols loaded.
'Hello.exe': Loaded 'C:\WINDOWS\System32\imm32.dll', No symbols loaded.
'Hello.exe': Loaded 'C:\WINDOWS\System32\msctf.dll', No symbols loaded.
'Hello.exe': Loaded 'C:\WINDOWS\System32\lpk.dll', No symbols loaded.
'Hello.exe': Loaded 'C:\WINDOWS\System32\usp10.dll', No symbols loaded.
'Hello.exe': Loaded 'C:\WINDOWS\System32\APSHook.dll', Binary was not
and not sure why??? You must include other things
not shown in your email, to cause these loads...

Simply, the pthreads DLL should work fine,
and the MS DLL products should be ok, but can not
speak for the other '3rd party' DLLS... which is
where I think the problem lies...

Anyway, hope this helps... 

Regards,

Geoff.


On Fri, 2009-06-12 at 15:00 +0200, Diego Ruiz wrote:
> Hello,
> 
> I manage to test a very small example in release mode. However the same
> example crashes in debug mode.
> 
> Thanks for any help or idea
> Diego
> 
> Ps: I am new to windows. I need to port my application from ubuntu to
> visual studio.
> 
> 
> Microsoft Visual Studio 2005
> New project -> WIN32 -> WIN32 Console application (name Hello)
> 
> •	Added #include <pthread.h> to stdafx.h
> •	Changed Hello.cpp:
> #include "stdafx.h"
> 
>  pthread_mutex_t mutex_bigbag   = PTHREAD_MUTEX_INITIALIZER;
> 
> /*! This program test compilation with the pthread library on windows */
> int _tmain(int argc, _TCHAR* argv[])
> {
> 
>     printf("hello\n");
>     getchar();
>     getchar();
> 
>     pthread_mutex_lock( &mutex_bigbag );
> 
>     pthread_mutex_unlock(&mutex_bigbag);
> 
>     return 0;
> }
> 
> •	QueueUserAPCEx:
> - Copy the driver and reboot as explained in the README file of directory
> - Copying the dll  (QuserEx.dll, QuserEx.lib) in working directory of
> solution (release, debug)
> - Copying the lib in an usefull_libs directory
> - using "net start alertdrv" in command prompt (cmd) in administrator mode
> 
> •	pthreads.2:
> - programs-> Visual studio -> visual studio tools -> VS command prompt
> - cd directory of pthreads.2
> - nmake clean VCE-inlined
> - copy the created dll in working directory of solution (release, debug)
> - copy of the library in usefull_libs directory
> 
> •	Test 1 in realease mode
> - Added path to inlcludes (pthread.h)
> - Added path to library in linker (usefull_libs)
> - Added library dependency in linker (pthreadVCE2.lib quserex.lib)
> - Compilation OK (0 errors, 0 warnings)
> - Test OK (prints hello and wait for char in terminal)
> 
> •	Test in debug mode
> 
> - Added path to inlcludes (pthread.h)
> - Added path to library in linker (usefull_libs)
> - Added library dependency in linker (pthreadVCE2.lib quserex.lib)
> - Compilation OK (0 errors, 0 warnings)
> - Test KO:
> 
> 'Hello.exe': Loaded 'C:\Users\ruiz\Documents\Visual Studio
> 2005\Projects\Tests\Hello\debug\Hello.exe', Symbols loaded.
> 'Hello.exe': Loaded 'C:\WINDOWS\System32\ntdll.dll', No symbols loaded.
> 'Hello.exe': Loaded 'C:\WINDOWS\System32\kernel32.dll', No symbols loaded.
> 'Hello.exe': Loaded 'C:\Users\ruiz\Documents\Visual Studio
> 2005\Projects\Tests\Hello\debug\pthreadVCE2.dll', Symbols loaded.
> 'Hello.exe': Loaded 'C:\Users\ruiz\Documents\Visual Studio
> 2005\Projects\Tests\Hello\debug\msvcr80.dll', No symbols loaded.
> 'Hello.exe': Loaded 'C:\WINDOWS\System32\msvcrt.dll', No symbols loaded.
> 'Hello.exe': Loaded 'C:\WINDOWS\System32\wsock32.dll', No symbols loaded.
> 'Hello.exe': Loaded 'C:\WINDOWS\System32\ws2_32.dll', No symbols loaded.
> 'Hello.exe': Loaded 'C:\WINDOWS\System32\advapi32.dll', No symbols loaded.
> 'Hello.exe': Loaded 'C:\WINDOWS\System32\rpcrt4.dll', No symbols loaded.
> 'Hello.exe': Loaded 'C:\WINDOWS\System32\nsi.dll', No symbols loaded.
> 'Hello.exe': Loaded
> 'C:\WINDOWS\winsxs\x86_microsoft.vc80.debugcrt_1fc8b3b9a1e18e3b_8.0.50727.762_none_24c8a196583ff03b\msvcr80d.dll',
> Symbols loaded.
> 'Hello.exe': Loaded 'C:\WINDOWS\System32\user32.dll', No symbols loaded.
> 'Hello.exe': Loaded 'C:\WINDOWS\System32\gdi32.dll', No symbols loaded.
> 'Hello.exe': Loaded 'C:\WINDOWS\System32\imm32.dll', No symbols loaded.
> 'Hello.exe': Loaded 'C:\WINDOWS\System32\msctf.dll', No symbols loaded.
> 'Hello.exe': Loaded 'C:\WINDOWS\System32\lpk.dll', No symbols loaded.
> 'Hello.exe': Loaded 'C:\WINDOWS\System32\usp10.dll', No symbols loaded.
> 'Hello.exe': Loaded 'C:\WINDOWS\System32\APSHook.dll', Binary was not
> built with debug information.
> First-chance exception at 0x77943387 in Hello.exe: 0xC0000005: Access
> violation writing location 0x00000014.
> R6034
> An application has made an attempt to load the C runtime library incorrectly.
> Please contact the application's support team for more information.
> Windows has triggered a breakpoint in Hello.exe.
> 
> This may be due to a corruption of the heap, and indicates a bug in
> Hello.exe or any of the DLLs it has loaded.
> 
> The output window may have more diagnostic information
> First-chance exception at 0x77909cac in Hello.exe: 0xC0000142: DLL
> Initialization Failed.
> Unhandled exception at 0x77909cac in Hello.exe: 0xC0000142: DLL
> Initialization Failed.
> Hello.exe has triggered a breakpoint
> First-chance exception at 0x769e8f21 in Hello.exe: 0xC0000005: Access
> violation reading location 0x769e8f21.
> 
> 
>  *** A stack buffer overrun occurred in "c:\users\ruiz\documents\visual
> studio 2005\projects\tests\hello\debug\Hello.exe" :
> 
> This is usually the result of a memory copy to a local buffer or structure
> where the size is not properly calculated/checked.
> If this bug ends up in the shipping product, it could be a severe security
> hole.
> The stack trace should show the guilty function (the function directly
> above __report_gsfailure).
>  *** enter .exr 779C9320 for the exception record
>  *** then kb to get the faulting stack
> 
> Windows has triggered a breakpoint in Hello.exe.
> 
> This may be due to a corruption of the heap, and indicates a bug in
> Hello.exe or any of the DLLs it has loaded.
> 
> The output window may have more diagnostic information
> Windows has triggered a breakpoint in Hello.exe.
> 
> This may be due to a corruption of the heap, and indicates a bug in
> Hello.exe or any of the DLLs it has loaded.
> 
> The output window may have more diagnostic information
> The program '[5584] Hello.exe: Native' has exited with code -1073740791
> (0xc0000409).


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-06-12 16:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <58344da04430a2f0b57d52a9e514b98d.squirrel@mmp.sipr-dc.ucl.ac.be>
2009-06-12 13:00 ` working release test failed in debug mode Diego Ruiz
2009-06-12 16:09   ` Geoff McLane

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).