c++ - Segmentation fault when calling function from shared version of library -
i have application needs set logging callback used library report information. compiled library statically, need use dll. when application calls function test failure condition, library supposed log reason function failed using callback. works without issue when linked statically, causes segmentation fault when linked dynamically. happens function called, , cannot step logging callback.
my application able call api functions defined in dll, dll function causes fault attempts call logging callback. happens when use stub function built library , application not try use custom callback.
my library written in c, application c++ gui using qt. use qt creator build library (mingw), library not use qt libraries.
here definition of logging callback type:
typedef void __attribute__((cdecl)) logfn(char const * const fname, unsigned int const line, loglvl const level, unsigned long long const time, err const err, char const * const reason);
here declaration , example call of logging function, global library:
logfn * debuglogfn = logdflt; debuglogfn(log_fname, __line__, log_warn_enum, curtime(), err_x_enum, "something");
logdflt stub function library uses before application specifies custom callback:
void __attribute__((cdecl)) logdflt(char const * const fname, unsigned int const line, loglvl const level, unsigned long long const time, err const err, char const * const reason) { // nothing }
this works when link statically, when setting callback static function of 1 of application's classes.
also, application execute when linked dynamically, long don't pass bad input dll function, since causes try call log function.
stack trace:
0 ?? 1 test_create_destroy test.c 225 0x40aaec 2 test::run test.cpp 70 0x40408f 3 qthreadprivate::start(void*)*4 407 0x6b798b92 4 msvcrt!_itow_s c:\windows\syswow64\msvcrt.dll 0x75551287 5 msvcrt!_endthreadex c:\windows\syswow64\msvcrt.dll 0x75551328 6 kernel32!basethreadinitthunk c:\windows\syswow64\kernel32.dll 0x75cd337a 7 ntdll!rtlinitializeexceptionchain c:\windows\system32\ntdll.dll 0x777d92e2 8 ntdll!rtlinitializeexceptionchain c:\windows\system32\ntdll.dll 0x777d92b5 9 ??
Comments
Post a Comment