CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 15
  1. #1
    Join Date
    Feb 2009
    Posts
    48

    Question Compilee only runs under debugger

    Hello there I need some clue, got a compiled x64 image but it does crash if run.
    Interesting that it finishes successfully if run under debugger (WinDbg).
    It indicates similar problem I had in past with 32bit app but can't remember yet what was the solution. The compilee uses no compression.
    Any hints?

  2. #2
    Join Date
    Mar 2001
    Posts
    2,529

    Re: Compilee only runs under debugger

    Hmmm maybe you have some sort of problems with the way you are allocating memory. Possibly you are allocating memory and not deleting it. Perhaps you are attempting to access memory outside of the memory area you allocated. The debugger is alot more accepting of errors, bad coding practice and memory exceptions, than usual.

    HTH,
    ahoodin
    To keep the plot moving, that's why.

  3. #3
    Join Date
    Feb 2009
    Posts
    48

    Re: Compilee only runs under debugger

    I don't have too much experience with WinDbg thus I don't know how stronly it protects application environment but letting run the same application compiled as x86 target it runs fine even standalone. So I think the problem is due 64bit image.
    The problem is that I can't debug anything since as I wrote it runs fine under debugger. Thus I even can't see where it crashes.

  4. #4
    Join Date
    Jan 2009
    Posts
    1,689

    Re: Compilee only runs under debugger

    It's also possible that you are expecting something to be initialized somewhere that doesn't. The debugger might either initialize it for you, or catch and recover from the problem. It's also possible that you are overrunning the bounds of an array. A lot of debuggers pad either side of a chunk of memory for debugging purposes, you might be running into that buffer and not knowing it. This is why unit tests (run outside the debugger) are so important.

  5. #5
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,656

    Re: Compilee only runs under debugger

    Quote Originally Posted by Anakunda View Post
    The problem is that I can't debug anything since as I wrote it runs fine under debugger. Thus I even can't see where it crashes.
    Could you please clarify that?
    Do you run debug or release build under debugger?
    Are you saying that the SAME build runs OK under debugger and fails when run by itself?
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinWindows - replacement windows manager for Visual Studio, and more...

  6. #6
    Join Date
    Feb 2009
    Posts
    48

    Re: Compilee only runs under debugger

    Quote Originally Posted by VladimirF View Post
    Could you please clarify that?
    Do you run debug or release build under debugger?
    Are you saying that the SAME build runs OK under debugger and fails when run by itself?
    I have tried to make both release and debug build. In both cases the image crashes outside debugger, in bothh cases it runs fine under it. The only difference is rls build invokes message about crash while debug build makes windows warning sound then stops without crash notify, thus optimizations as well as debug code are not on cause.

  7. #7
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,656

    Re: Compilee only runs under debugger

    Two more questions:
    1. Is your environment set up OK? I mean - could you build and run 64-bit "Hello World!" app outside of your debugger?
    2. Is there any chance that your app specifically checks for debugger and calls its services?
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinWindows - replacement windows manager for Visual Studio, and more...

  8. #8
    Join Date
    Feb 2009
    Posts
    48

    Re: Compilee only runs under debugger

    Quote Originally Posted by VladimirF View Post
    Two more questions:
    1. Is your environment set up OK? I mean - could you build and run 64-bit "Hello World!" app outside of your debugger?
    Yes, runs fine.

    Quote Originally Posted by VladimirF View Post
    2. Is there any chance that your app specifically checks for debugger and calls its services?
    I don't think so, it's an open source platform independent audio encoder.

    Moreover I was doing an debug build earlier turning off all optimizations and it ran well outside debugger, trying to reproduce this build with same settings today generated an crashing image, so it must be something that happens in random.

  9. #9
    Join Date
    Jan 2009
    Posts
    1,689

    Re: Compilee only runs under debugger

    Does your program create a log file? That's always invaluable when debugging programs like that.

  10. #10
    Join Date
    Feb 2009
    Posts
    48

    Re: Compilee only runs under debugger

    Hmm I don't think so, but it atleast prints the startup banner (console), the crash happens exactly when starting conversion.

  11. #11
    Join Date
    Jan 2009
    Posts
    1,689

    Re: Compilee only runs under debugger

    Try putting more logging, you have given us very little to go on.q

    Questions I have:
    Is your program threaded? POSIX, boost, or MS?
    Have you even pinpointed the method that is crashing?
    Could you post the code that is problematic?
    When you switched to 64-bit, did you remember to switch linking dependancies?
    Are you loading any libraries using dlopen (or whatever the win equivalent is)?
    Do you ever place a pointer in anything other than a pointer primitive?
    Are you mixing 32-bit and 64-bit libraries? Do any of their interfaces use pointers?

  12. #12
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Compilee only runs under debugger

    Quote Originally Posted by Anakunda View Post
    Hmm I don't think so, but it atleast prints the startup banner (console), the crash happens exactly when starting conversion.
    If you're using Visual Studio, try creating a dummy project, but have the Debugging option point to the executable you're trying to debug. See if the app now crashes while debugging.

    If you are using Windows, better still if you actually created a crash dump for your program. There are ways to programatically create a crash dump by using the functions in DbgHelp.dll. There are articles here and elsewhere that discuss how to do this. Then all you need is to take the created dump file, load it as a project in Visual Studio, and run the dump file to identify where the crash occurs.

    Regards,

    Paul McKenzie
    Last edited by Paul McKenzie; May 2nd, 2011 at 05:15 PM.

  13. #13
    Join Date
    Feb 2009
    Posts
    48

    Re: Compilee only runs under debugger

    Quote Originally Posted by ninja9578 View Post
    Is your program threaded? POSIX, boost, or MS?
    No, it's plain C

    Quote Originally Posted by ninja9578 View Post
    Have you even pinpointed the method that is crashing?
    No I only guess which library might concern.

    Quote Originally Posted by ninja9578 View Post
    When you switched to 64-bit, did you remember to switch linking dependancies?
    What dependencies do you mean? I have switched to 64bit versions of all libraries.

    Quote Originally Posted by ninja9578 View Post
    Are you loading any libraries using dlopen (or whatever the win equivalent is)?
    Do you ever place a pointer in anything other than a pointer primitive?
    Could you post the code that is problematic?
    That's not my project I leave the source as is.
    It doesnot use any 3rd party dlls except MSVC10 runtime and Intel Support DLL.
    The source including binaries is uploaded here: http://www.mediafire.com/?b06qxs0uo1zlkn6

    Quote Originally Posted by ninja9578 View Post
    Are you mixing 32-bit and 64-bit libraries? Do any of their interfaces use pointers?
    sure no, every lib I recompiled for x64

    Unfortunatelly I don't use Visual Studio IDE, only MSVC libraries. This project is compiled by IntelC++.

  14. #14
    Join Date
    Jan 2009
    Posts
    1,689

    Re: Compilee only runs under debugger

    Are MSVC libraries compatible with IntelC++? VC++ mangles function names in weird ways, it's not regular GCC naming. I've always adhered to the policy of not mixing compilers. If compiling with MSVC, use MSVC compiled libraries, if using MinGW, only use MinGW compiled libraries. What if you use IntelC++ to compile your libraries?

  15. #15
    Join Date
    Feb 2009
    Posts
    48

    Re: Compilee only runs under debugger

    Yes Intel and MS libraries are mutually compatible.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured