2012-03-21 2 views
1

Mac OS X (Qt 4.8.0)에서 작동하지만 Ubuntu Linux (Qt 4.7.4)에서 작동하는 Qt에 대한 Lua 바인딩이 있습니다. Qt 코드는 dlopen으로로드 된 다음 app-> exec()로 Qt에 전달됩니다.공유 라이브러리로로드 할 때 Qt를 올바르게 종료하는 방법은 무엇입니까?

루아 코드 :

require 'mimas' -- Load shared library mimas.so linked to Qt libs 
app = mimas.Application() -- Just a wrapper around QApplication 
app:exec() 
-- In some callback: app:quit() 

루아가 종료 (응용 프로그램 후 : 간부 인() 반환), 그것은 SIGSEGV에서 끝나는 '마스'공유 라이브러리에 우 dlclose 않습니다. 백 트레이스 :

Program received signal SIGSEGV, Segmentation fault. 
QList<QFactoryLoader*>::removeAll (this=0x0, [email protected]) 
    at ../../include/QtCore/../../src/corelib/tools/qlist.h:760 
760 ../../include/QtCore/../../src/corelib/tools/qlist.h: No such file or directory. 
    in ../../include/QtCore/../../src/corelib/tools/qlist.h 
(gdb) bt 
#0 QList<QFactoryLoader*>::removeAll (this=0x0, [email protected]) 
    at ../../include/QtCore/../../src/corelib/tools/qlist.h:760 
#1 0x0131126c in QFactoryLoader::~QFactoryLoader (this=0x8104a48, 
    __in_chrg=<optimized out>) at plugin/qfactoryloader.cpp:208 
#2 0x01311302 in QFactoryLoader::~QFactoryLoader (this=0x8104a48, 
    __in_chrg=<optimized out>) at plugin/qfactoryloader.cpp:209 
#3 0x009143a8 in QGlobalStaticDeleter<QFactoryLoader>::~QGlobalStaticDeleter (
    this=0x11c3200, __in_chrg=<optimized out>) 
    at ../../include/QtCore/../../src/corelib/global/qglobal.h:1825 
#4 0x001e7d2b in __cxa_finalize() from /lib/i386-linux-gnu/libc.so.6 
#5 0x00842a94 in __do_global_dtors_aux() 
    from /usr/lib/i386-linux-gnu/libQtGui.so.4 
[snip] 
#13 0x0016bd28 in dlclose() from /lib/i386-linux-gnu/libdl.so.2 

이 메모리 버그로 끝나지 않게 Qt를 올바르게 닫을 수 있습니까?

문제는 qt_factory_loaders()이 NULL을 반환하는 것으로 보입니다. 상황이 바뀌 었는지 확인하기 위해 Qt 4.8.0을 사용해 보겠습니다.

[편집] 문제점 (Lua와 관련이 없음)을 좁히고 qt에 bug report을 채울 수 있습니다.

답변

0

하지 완전히 확인 질문이 무엇인지,하지만 당신은 명시 적으로 우 dlclose() 아마도 당신이 무엇을 원하는 app:quit()

+0

응용 프로그램은 : 간부 인()가 반환 : 종료()는 Qt는이 중단 및 응용 방법이다. 이 단계 후에 충돌이 발생합니다. – gaspard

0

으로 종료 Qt는 응용 프로그램을 알 수 있습니까? 예를 들어

http://www.kernel.org/doc/man-pages/online/pages/man3/dlsym.3.html

The function dlclose() decrements the reference count on the dynamic library 
    handle handle. If the reference count drops to zero and no other loaded 
    libraries use symbols in it, then the dynamic library is unloaded. 

    The function dlclose() returns 0 on success, and nonzero on error. 

:

#ifdef MAC_OS 
    // unload library for MAC 
#else //if linux 
    dlclose(lib_handle); 
#endif 
+0

백 트레이스에서 볼 수 있듯이 'dlclose'는 lua_close 작업 (프레임 13)의 일부로 Lua에 의해 호출됩니다. 충돌은 'dlclose'중에 발생합니다. – gaspard

관련 문제