Opened 8 years ago
Closed 7 years ago
#6384 closed defect (fixed)
Access violation in Visual Studio when compiled with Multi-threaded Debug DLL
Reported by: | mcserep | Owned by: | warmerdam |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | default | Version: | svn-trunk |
Severity: | normal | Keywords: | |
Cc: |
Description (last modified by )
I am building an application using the GDAL/OGR library and have faced a really strange issue, namely getting an access violation error when running my program compiled with Multi-threaded Debug DLL (/MDd
) runtime library option. The following example is a minimal sample to demonstrate the problem:
#include <ogr_geometry.h> int main(int argc, char* argv[]) { OGRPoint *point = new OGRPoint; delete point; // segmentation fault return 0; }
Similar problem occurs with other OGR types in the GDAL/OGR library, so it is not related to the OGRPoint
class. However there is no issue when the memory is allocated on the stack and not on the heap.
The code executes fine when I use the Multi-threaded DLL configuration instead. (So basically Release mode is good, but Debug mode runs into the mentioned access violation error.) The program also runs fine on Linux compiled with g++
.
The callstack is the following:
ntdll.dll!_RtlReportCriticalFailure@8() Unknown ntdll.dll!_RtlpHeapHandleError@4() Unknown ntdll.dll!_RtlpLogHeapFailure@24() Unknown ntdll.dll!RtlFreeHeap() Unknown AcLayers.dll!6d7158bf() Unknown [Frames below may be incorrect and/or missing, no symbols loaded for AcLayers.dll] gdal201.dll!0f87bdbd() Unknown TestProject.exe!main(int argc, char * * argv) Line 7 C++ [External Code]
Change History (4)
comment:1 by , 8 years ago
Component: | OGR_SRS → default |
---|---|
Description: | modified (diff) |
Summary: | Deleting OGRSpatialReference object runs into segmentation fault → Access violation in Visual Studio when compiled with Multi-threaded Debug DLL |
After some searching I realized that this issue have been raised multiple times already:
The issue was not fixed and since the default runtime library linking in Visual Studio for Debug configuration is
/MDd
, it can easily cause further problems to others too. I think when the library is compiled with theDEBUG
flag, it should use/MDd
instead of/MD
.