init上的wxwidgets和wxpdfdoc崩溃

发布于 2025-01-20 02:31:30 字数 5161 浏览 0 评论 0原文

我在程序初始化时发生崩溃,没有明显的原因,我看不到。我的调用堆栈是:

    1  std::char_traits<wchar_t>::assign          char_traits.h       420  0x5555557691cf 
    2  std::wstring::_M_set_length                basic_string.h      221  0x55555576c865 
    3  std::wstring::_M_assign                    basic_string.tcc    274  0x55555576da33 
    4  std::wstring::assign                       basic_string.h      1370 0x55555576cc1b 
    5  std::wstring::operator=                    basic_string.h      700  0x55555576bb38 
    6  wxString::operator=                        string.h            1892 0x5555557697a5 
    7  wxFileName::Assign                         filename.cpp        405  0x55555616e130 
    8  wxFileName::Assign                         filename.cpp        529  0x55555616e723 
    9  wxFileName::wxFileName                     filename.h          149  0x555555824988 
    10 wxPathList::Add                            filefn.cpp          118  0x555556167e06 
    11 wxPdfFontManagerBase::wxPdfFontManagerBase string.h            3603 0x555555db8a8a 
    12 wxPdfFontManager::wxPdfFontManager         pdffontmanager.cpp  1642 0x555555db8c30 
    13 wxPdfDocumentModule::OnInit                pdffontmanager.cpp  1817 0x555555db8c70 
    14 wxModule::Init                             module.h            33   0x555556193e59 
    15 wxModule::DoInitializeModule               module.cpp          137  0x5555561931b6 
    16 wxModule::InitializeModules                module.cpp          168  0x555556193811 
    17 DoCommonPostInit                           init.cpp            282  0x555556181729 
    18 wxEntryStart                               init.cpp            348  0x555556181ae0 
    19 wxInitialize                               init.cpp            541  0x555556181f76 
    20 wxInitializer::wxInitializer               init.h              92   0x555556182221 
    21 wxEntry                                    init.cpp            474  0x555556181d53 
    22 wxEntry                                    init.cpp            516  0x555556181ebe 
    23 main                                       myprogram.cpp       490  0x555555766ebc 

这里, __c1 不存在于

    static _GLIBCXX17_CONSTEXPR void
    assign(char_type& __c1, const char_type& __c2) _GLIBCXX_NOEXCEPT
    { __c1 = __c2; }

其他 wxStrings 中,在使用 wxPdfDoc 代码之前很高兴地分配给它。 我必须确保 wxPdfDocument 在 CMakeLists 中的其他库之前链接,否则我会遇到静态初始化顺序失败。 即来自 /usr/local/lib/libwx_baseu 的 _GLOBAL__sub_I_strconv.cpp () 的“程序收到信号 SIGFPE,算术异常”,其中 wxCSConv::DoCreate 失败。我认为这是来自 wxpdfdoc 库中某个静态的地方,该库在 wxWidgets 初始化之前被初始化,但我不知道在哪里,因此库链接顺序的更简单的解决方法。

因此我这样链接: target_link_libraries(${PROJECT_NAME} PRIVATE -lpthread -lwxcode_gtk3u_pdfdoc-3.1 ${wxWidgets_LIBRARIES} ${MYSQL_LIBS} -lodbc)

我还确保它指向使用我自己的 wxWidgets 树而不是系统 wxGTK 的东西:

    set(wxWidgets_CONFIG_EXECUTABLE /home/rich/wxWidgets/build-debug/wx-config)
    set(wxWidgets_ROOT_DIR /home/rich/wxWidgets)
    set(wxWidgets_LIB_DIR /home/rich/wxWidgets/build-debug/lib)
    set(wxWidgets_INCLUDE_DIRS /home/rich/wxWidgets/build-debug/lib/wx/include/gtk3-unicode-static-3.1)
    find_package(wxWidgets COMPONENTS core base webview qa adv aui html propgrid ribbon richtext stc xml REQUIRED)
    include(${wxWidgets_USE_FILE})
    link_directories(/home/rich/wxpdfdoc/build-gtk/.libs)

我正在使用 Ubuntu 20.04 并使用 Git 分支,构建我自己的版本树。对于我正在使用的 wxWidgets(是的,我知道很多都是默认值,但我很明确):

../configure --disable-shared --enable-unicode --prefix="$(pwd)" --enable-stc --enable-ipc --enable-base64 --enable-exceptions --enable-fontenum --enable-fs_archive --enable-stdpaths --enable-sysoptions --enable-threads --enable-url --enable-aui  --enable-graphics_ctx  --enable-printarch --enable-timer --enable-ribbon --enable-webview --enable-display --enable-splash --enable-snglinst --enable-printfposparam --with-opengl --with-expat=builtin --with-cxx=11 --enable-cxx11 --enable-stl --enable-std_iostreams --enable-std_string --enable-ftp --enable-http --enable-fileproto --enable-sockets --enable-ipv6 --enable-dataobj --enable-ipc --enable-any --enable-arcstream --enable-backtrace --enable-cmdline --enable-datetime --enable-debugreport --enable-dynamicloader --enable-exceptions --enable-ffile --enable-file --enable-filehistory --enable-filesystem --enable-fontmap --enable-fs_inet --enable-fs_zip --enable-fsvolume --enable-fswatcher --enable-geometry --enable-sound --enable-stopwatch --enable-streams --enable-tarstream --enable-textbuf --enable-textfile --enable-variant --enable-zipstream --enable-protocol --enable-protocol-http --enable-protocol-ftp --enable-protocol-file --enable-html --enable-htmlhelp --enable-propgrid --enable-svg --enable-clipboard --enable-dnd --enable-accel --enable-debug --with-libpng=builtin --with-libjpeg=builtin --with-zlib=builtin --with-libtiff=builtin --with-libcurl --with-gtk=3 --with-cxx=17 CXXFLAGS=-std=c++17

对于我正在使用的 wxPDFDoc:

../configure --with-wx-config=/home/rich/wxWidgets/build-debug/wx-config --disable-shared

我根本不知道为什么会发生这种情况 - 任何指针将不胜感激!

I am getting a crash on initialisation of my program for no obvious reason that I can see. My callstack is:

    1  std::char_traits<wchar_t>::assign          char_traits.h       420  0x5555557691cf 
    2  std::wstring::_M_set_length                basic_string.h      221  0x55555576c865 
    3  std::wstring::_M_assign                    basic_string.tcc    274  0x55555576da33 
    4  std::wstring::assign                       basic_string.h      1370 0x55555576cc1b 
    5  std::wstring::operator=                    basic_string.h      700  0x55555576bb38 
    6  wxString::operator=                        string.h            1892 0x5555557697a5 
    7  wxFileName::Assign                         filename.cpp        405  0x55555616e130 
    8  wxFileName::Assign                         filename.cpp        529  0x55555616e723 
    9  wxFileName::wxFileName                     filename.h          149  0x555555824988 
    10 wxPathList::Add                            filefn.cpp          118  0x555556167e06 
    11 wxPdfFontManagerBase::wxPdfFontManagerBase string.h            3603 0x555555db8a8a 
    12 wxPdfFontManager::wxPdfFontManager         pdffontmanager.cpp  1642 0x555555db8c30 
    13 wxPdfDocumentModule::OnInit                pdffontmanager.cpp  1817 0x555555db8c70 
    14 wxModule::Init                             module.h            33   0x555556193e59 
    15 wxModule::DoInitializeModule               module.cpp          137  0x5555561931b6 
    16 wxModule::InitializeModules                module.cpp          168  0x555556193811 
    17 DoCommonPostInit                           init.cpp            282  0x555556181729 
    18 wxEntryStart                               init.cpp            348  0x555556181ae0 
    19 wxInitialize                               init.cpp            541  0x555556181f76 
    20 wxInitializer::wxInitializer               init.h              92   0x555556182221 
    21 wxEntry                                    init.cpp            474  0x555556181d53 
    22 wxEntry                                    init.cpp            516  0x555556181ebe 
    23 main                                       myprogram.cpp       490  0x555555766ebc 

Here, __c1 doesn't exist inside

    static _GLIBCXX17_CONSTEXPR void
    assign(char_type& __c1, const char_type& __c2) _GLIBCXX_NOEXCEPT
    { __c1 = __c2; }

Other wxStrings are happily assigned to before the wxPdfDoc code gets used.
I had to ensure that wxPdfDocument was linked before the other libraries inside my CMakeLists because else I got the Static Initialization Order Fiasco.
ie a "Program received signal SIGFPE, Arithmetic exception" from _GLOBAL__sub_I_strconv.cpp () from /usr/local/lib/libwx_baseu, where wxCSConv::DoCreate fails. I think that's from some static somewhere in the wxpdfdoc library that is being initialised before wxWidgets has been initialised, but I don't know where hence the easier workaround of library link orders.

I am therefore linking like this:
target_link_libraries(${PROJECT_NAME} PRIVATE -lpthread -lwxcode_gtk3u_pdfdoc-3.1 ${wxWidgets_LIBRARIES} ${MYSQL_LIBS} -lodbc)

I am also ensuring it points to use my own wxWidgets tree instead of the system wxGTK stuff:

    set(wxWidgets_CONFIG_EXECUTABLE /home/rich/wxWidgets/build-debug/wx-config)
    set(wxWidgets_ROOT_DIR /home/rich/wxWidgets)
    set(wxWidgets_LIB_DIR /home/rich/wxWidgets/build-debug/lib)
    set(wxWidgets_INCLUDE_DIRS /home/rich/wxWidgets/build-debug/lib/wx/include/gtk3-unicode-static-3.1)
    find_package(wxWidgets COMPONENTS core base webview qa adv aui html propgrid ribbon richtext stc xml REQUIRED)
    include(${wxWidgets_USE_FILE})
    link_directories(/home/rich/wxpdfdoc/build-gtk/.libs)

I am using Ubuntu 20.04 and am using the Git branches, building my own versions of the tree. For wxWidgets I am using (yes I know lots are defaults but I am being explicit):

../configure --disable-shared --enable-unicode --prefix="$(pwd)" --enable-stc --enable-ipc --enable-base64 --enable-exceptions --enable-fontenum --enable-fs_archive --enable-stdpaths --enable-sysoptions --enable-threads --enable-url --enable-aui  --enable-graphics_ctx  --enable-printarch --enable-timer --enable-ribbon --enable-webview --enable-display --enable-splash --enable-snglinst --enable-printfposparam --with-opengl --with-expat=builtin --with-cxx=11 --enable-cxx11 --enable-stl --enable-std_iostreams --enable-std_string --enable-ftp --enable-http --enable-fileproto --enable-sockets --enable-ipv6 --enable-dataobj --enable-ipc --enable-any --enable-arcstream --enable-backtrace --enable-cmdline --enable-datetime --enable-debugreport --enable-dynamicloader --enable-exceptions --enable-ffile --enable-file --enable-filehistory --enable-filesystem --enable-fontmap --enable-fs_inet --enable-fs_zip --enable-fsvolume --enable-fswatcher --enable-geometry --enable-sound --enable-stopwatch --enable-streams --enable-tarstream --enable-textbuf --enable-textfile --enable-variant --enable-zipstream --enable-protocol --enable-protocol-http --enable-protocol-ftp --enable-protocol-file --enable-html --enable-htmlhelp --enable-propgrid --enable-svg --enable-clipboard --enable-dnd --enable-accel --enable-debug --with-libpng=builtin --with-libjpeg=builtin --with-zlib=builtin --with-libtiff=builtin --with-libcurl --with-gtk=3 --with-cxx=17 CXXFLAGS=-std=c++17

For wxPDFDoc I am using:

../configure --with-wx-config=/home/rich/wxWidgets/build-debug/wx-config --disable-shared

I have no idea why this is happening at all - any pointers would be appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

_失温 2025-01-27 02:31:30

您似乎没有指定-STD = C ++ 17在构建WXPDFDOC时,因此,除非您的编译器默认使用C ++ 17,否则它不会使用与WXWIDGETS相同的编译选项(它)是灾难的秘诀。您需要使用完全相同的选项(当然是相同的编译器)来构建所有内容。

You don't seem to specify -std=c++17 when building wxPdfDoc, so unless your compiler uses C++17 by default, it doesn't use the same compilation options as wxWidgets, which is a recipe for disaster. You need to use exactly the same options (and the same compiler, of course) for building everything.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文