CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Jun 2001
    Location
    USA
    Posts
    298

    app throws exception before winmain

    I have an MFC application that I'm attempting to debug and I've enabled all the exception breakpoint options. I get an exception before it executes any of my code. I've put a breakpoint at the earliest point I can get to (InitInstance) and it happens before that.

    Error says:

    First-chance exception at 0x7c919af2 in HIDCPS.exe:
    0xC0000005: Access violation writing location 0x00000010.

    I'm not sure how to interpret the stack trace, but it looks to be in the Windows DLLs?

    ntdll.dll!7c919af2()
    [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]
    ntdll.dll!7c901046()
    advapi32.dll!77dd6cf8()
    advapi32.dll!77dd6b57()
    PGPmapih.dll!0039175f()
    kernel32.dll!7c85b44f()
    PGPmapih.dll!003937f5()
    PGPmapih.dll!0039267b()
    PGPmapih.dll!003927ad()
    PGPmapih.dll!00392854()
    ntdll.dll!7c90118a()
    ntdll.dll!7c91b5d2()
    ntdll.dll!7c9162db()
    ntdll.dll!7c91585f()
    ntdll.dll!7c915721()
    ntdll.dll!7c91538b()
    ntdll.dll!7c9221b6()
    ntdll.dll!7c9211e4()
    ntdll.dll!7c90e457()
    HIDCPS.exe!CODBCFieldInfo::`vector deleting destructor'() + 0x4f bytes C++
    74958b84()

    This project was imported from VC6 - could I have a conflict somewhere in the CRT libs?

    Or any other comments, would be welcome.
    Thanks.

  2. #2
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,637

    Re: app throws exception before winmain

    Unless it's actually crashing, you can ignore those messages.

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

    Re: app throws exception before winmain

    Quote Originally Posted by Dave C View Post
    I have an MFC application that I'm attempting to debug and I've enabled all the exception breakpoint options. I get an exception before it executes any of my code.
    Not correct.

    Your code includes any global and static objects that are created. Obviously, one of your objects is a vector or has a vector as a member.
    Code:
    HIDCPS.exe!CODBCFieldInfo::`vector deleting destructor'()  + 0x4f bytes	C++
    So your code is being executed -- it has something to do with your global or static data that is being instantiated.

    Regards,

    Paul McKenzie

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

    Re: app throws exception before winmain

    Quote Originally Posted by GCDEF View Post
    Unless it's actually crashing, you can ignore those messages.
    Are you serious? Ignore the access violation that was caught?
    You are at least guaranteed that something was NOT written as was expected, and you don't know who caught that exception, and if they recovered from it.
    One can set their debugger to break on first-chance exception to track what is going on.
    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...

  5. #5
    Join Date
    Jun 2001
    Location
    USA
    Posts
    298

    Re: app throws exception before winmain

    Quote Originally Posted by Paul McKenzie View Post
    Not correct.

    Your code includes any global and static objects that are created. Obviously, one of your objects is a vector or has a vector as a member.
    Code:
    HIDCPS.exe!CODBCFieldInfo::`vector deleting destructor'()  + 0x4f bytes	C++
    So your code is being executed -- it has something to do with your global or static data that is being instantiated.

    Regards,

    Paul McKenzie
    From what I can Google, that CODBCFieldInfo has something to do with CRecordset. There is a global object (a class of mine) that includes CDatabase and CRecordset objects, but the exception occurs well before the constructor of my class.

    Is there any way to know from the address in the call stack which of my static or global variables might be causing this? All I get is the disassembly and I don't know how to interpret that.

    Thanks

  6. #6
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,637

    Re: app throws exception before winmain

    Quote Originally Posted by VladimirF View Post
    Are you serious? Ignore the access violation that was caught?
    You are at least guaranteed that something was NOT written as was expected, and you don't know who caught that exception, and if they recovered from it.
    One can set their debugger to break on first-chance exception to track what is going on.
    I said unless the app is crashing, first-chance exceptions can usually be ignored. Yes I'm serious.

    http://blogs.msdn.com/b/davidklinems...12/438061.aspx
    Does a first chance exception mean there is a problem in my code?
    First chance exception messages most often do not mean there is a problem in the code.

  7. #7
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: app throws exception before winmain

    You might find some clue in the map file. If it's possible (i.e. not to much work) you can comment that global object and check if the issue still exists. Also check that you don't link explicitly with some VC6 libs.
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    https://visualstudio.microsoft.com/vs

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

    Re: app throws exception before winmain

    Quote Originally Posted by Dave C View Post
    From what I can Google, that CODBCFieldInfo has something to do with CRecordset. There is a global object (a class of mine) that includes CDatabase and CRecordset objects,
    Please show this class.
    but the exception occurs well before the constructor of my class.
    How are you able to verify this? We can't verify your claims that the exception occurs before the constructor.

    Regards,

    Paul McKenzie

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

    Re: app throws exception before winmain

    Quote Originally Posted by Dave C View Post
    Is there any way to know from the address in the call stack which of my static or global variables might be causing this?
    As I said in post #4 above, set your debugger to break when Access Violation exception is thrown.
    Go to Debug -> Exceptions… and place a checkmark:
    Attached Images Attached Images
    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...

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