[問題] wxwidgets的wxString出現segmentation fault

看板C_and_CPP (C/C++)作者時間15年前 (2011/05/12 11:57), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) Linux ubuntu10.04 gcc 4.4.3 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) wxwidgets 想請問有沒有人遇過相同的問題 class ProcessTrans { public: wxString mstatement; ... } void function_a() { ProcessTrans curProcessTrans; ...... lengthUnknownString = (char*)dataItemContent; lengthUnknownString[ dataItemSize ] = '\0'; curProcessTrans.mStatement = wxString(lengthUnknownString, wxConvUTF8 ); ... } 在function_a結束後 程式呼叫~ProcessTrans的過程中 因為mStatement的關係出現了segmentatino fault 不知道是不是 lengthUnknownString 長度的關係 比較短的 lengthUnknownString 就不會出現問題 用gdb bt後的結果 Program received signal SIGSEGV, Segmentation fault. 0x080a7e90 in wxStringData::IsEmpty (this=0x79616d14) at /usr/local/include/wx-2.8/wx/string.h:226 226 bool IsEmpty() const { return (nRefs == -1); } (gdb) bt #0 0x080a7e90 in wxStringData::IsEmpty (this=0x79616d14) at /usr/local/include/wx-2.8/wx/string.h:226 #1 0x080a7ed3 in wxStringData::Unlock (this=0x79616d14) at /usr/local/include/wx-2.8/wx/string.h:243 #2 0x080a7ff1 in ~wxStringBase (this=0xbfffeec0, __in_chrg=<value optimized out>) at /usr/local/include/wx-2.8/wx/string.h:396 #3 0x080a80df in ~wxString (this=0xbfffeec0, __in_chrg=<value optimized out>) at /usr/local/include/wx-2.8/wx/string.h:660 #4 0x080d366c in ~ProcessTrans (this=0xbfffeeb8, __in_chrg=<value optimized out>) at ./anim.h:380 #5 0x080bf901 in MyRunPathgFrame::HandlePathgProcessData (this=0x8fe2100) at ./anim.cpp:3009 #6 0x080c06d3 in MyRunPathgFrame::OnIdle (this=0x8fe2100, event=...) at ./anim.cpp:4602 #7 0x0826f1b9 in wxEvtHandler::ProcessEventIfMatches(wxEventTableEntryBase const&, wxEvtHandler*, wxEvent&) () #8 0x0826f320 in wxEvtHandler::SearchDynamicEventTable(wxEvent&) () #9 0x082700db in wxEvtHandler::ProcessEvent(wxEvent&) () #10 0x0814cbd2 in wxAppBase::SendIdleEvents(wxWindow*, wxIdleEvent&) () #11 0x0814cdb6 in wxAppBase::ProcessIdle() () #12 0x0810ad0b in wxapp_idle_callback () #13 0x008df661 in ?? () from /lib/libglib-2.0.so.0 #14 0x008e15e5 in g_main_context_dispatch () from /lib/libglib-2.0.so.0 #15 0x008e52d8 in ?? () from /lib/libglib-2.0.so.0 #16 0x008e5817 in g_main_loop_run () from /lib/libglib-2.0.so.0 #17 0x0033b3c9 in gtk_main () from /usr/lib/libgtk-x11-2.0.so.0 #18 0x081b6d1c in wxEventLoop::Run() () #19 0x0814cc1d in wxAppBase::MainLoop() () #20 0x0822ffdd in wxEntry(int&, wchar_t**) () #21 0x0805e7e3 in main (argc=1, argv=0xbffff4a4) at ./gred.cpp:46 想請問有沒有人知道該如何解決 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.42.145
文章代碼(AID): #1Dorh2G5 (C_and_CPP)
文章代碼(AID): #1Dorh2G5 (C_and_CPP)