Rich
Rich

Reputation: 3762

c++ Debugging Exception c0000139

I am currently trying to get to the bottom of a client crash with one of our applications. I have wrapped the app in an exception handler which creates a mini-dump when the crash occurs.

The application crashes with the exception c0000139 (of which there isn't a huge amount of documentation).

The callstack looks like this

ntdll.dll!_RtlRaiseStatus@4()  + 0x26 bytes 
ntdll.dll!_LdrpSnapThunk@32()  + 0x26f48 bytes  
ntdll.dll!_LdrpSnapIAT@16()  + 0xd9 bytes   
ntdll.dll!_LdrpHandleOneOldFormatImportDescriptor@16()  + 0x7a bytes    
ntdll.dll!_LdrpHandleOldFormatImportDescriptors@16()  + 0x2e bytes  
ntdll.dll!_LdrpWalkImportDescriptor@8()  + 0x11d bytes  
ntdll.dll!_LdrpLoadDll@24()  - 0x265 bytes  
ntdll.dll!_LdrLoadDll@16()  + 0x110 bytes   
kernel32.dll!_LoadLibraryExW@12()  + 0xc8 bytes 
odbc32.dll!_ODBCLoadLibraryEx@12()  + 0x29 bytes    
odbc32.dll!_LoadDriver@12()  + 0x119f bytes 
odbc32.dll!_SQLDriverConnectW@32()  + 0x1be bytes   
odbc32.dll!_SQLDriverConnect@32()  + 0x125 bytes

It looks like the program is trying to create a database connection (to Oracle via ODBC) and somehow failing to either find the dll or has found a dll with the wrong entry point.

I was wondering if anyone could offer advice an how to track this problem down further, or if anyone has experienced this problem I'd be interested in hearing how you solved it.

Thanks in advance

Rich

Upvotes: 1

Views: 5401

Answers (4)

TarmoPikaro
TarmoPikaro

Reputation: 5223

In my own case I had similar problem.

And root cause was that .dll was loaded from incorrect path - python27.dll was residing in C:\Windows\System32 (1) and in local application directory (2).

Dll from (1) was loaded causing further (ntdll.dll) in testhost.net472.exe: 0xC0000139: Entry Point Not Found. exception to occur.

Fix was rather simple:

LoadLibrary(libname);

was replaced with:

LoadLibraryExW(libname, nullptr, LOAD_WITH_ALTERED_SEARCH_PATH);

This modifies .dll search order to find .dll first from application folder, not system folder.

Upvotes: 0

Rich
Rich

Reputation: 3762

Thanks for all the responses.

Turns out (at least this seems like it was the problem) that we had a configuration problem. Half of the software was set to load the 9i drivers and half of the software was expecting the 10g drivers.

It's early days yet and we need to test this, however it seems very likely that this was the cause.

Cheers Rich

Upvotes: 0

deemok
deemok

Reputation: 2753

Enable loader snaps (gflags -i yourapp.exe +sls) and have it pinpoint the library its failing to find/load (starting the program under the debugger will spew all the loader diagnostics).

Alternatively, get the name of the library from the crash dump by examining parameters of LoadLibraryExW call.

Upvotes: 1

mmmmmm
mmmmmm

Reputation: 32661

That exception code is Entry point not found - something is trying to load a DLL and the DLL cannot find all the DLLs it needs.

Use depends.exe to show what the DLL requires.

Upvotes: 1

Related Questions