[osgeo4w-dev] Crash in thread on FILE opened by a lib compiled by MinGW

Radim Blazek radim.blazek at gmail.com
Fri Jun 19 02:04:39 PDT 2015


Hi,

I am trying to fix QGIS (compiled by MSVC) crashes with GRASS 7
(compiled by MinGW) on Windows. I have traced down that it crashes
when functions are called on a FILE structure which was created by a
library (libgrass_gis.7.0.0.dll in this case) compiled by MinGW in a
thread in an application compiled by MSVC. It crashes in Microsoft
_lock_file(FILE *pf) where pf is casted to _FILEX:

    EnterCriticalSection( &(((_FILEX *)pf)->lock) );

where _FILEX is defined as

    typedef struct {
        FILE f;
        CRITICAL_SECTION lock;
    }   _FILEX;

Most probably, when the file is opened in a library compiled by MinGW,
it is not allocated as _FILEX but as FILE and accessing the lock is
causing the crash. Does anybody have deeper insight into the problem
and how to solve it?

It does not happen with GRASS 6 compiled with MinGW. Are you aware of
any difference between GRASS 6 and 7 build in OSGeo4W? E.g. different
GCC version or compilation options?

It works if the library is compiled by MSVC.

Radim


More information about the osgeo4w-dev mailing list