gpt4 book ai didi

c++ - AIX 上的 std::locale::operator=(std::locale const&) 崩溃

转载 作者:太空宇宙 更新时间:2023-11-04 13:02:51 25 4
gpt4 key购买 nike

我对 AIX 有点陌生,遇到了一个奇怪的问题。我有两台 AIX 机器,我的 C++ 应用程序在一台上运行,在另一台上崩溃。

当我检查安装的软件包 (rpm -qa) 时,我观察到一个区别,对于第一台机器,所有 rpm 的扩展名都以 .ppc 结尾,而对于第二台机器,则不是。我的 cpp 应用程序在第二台机器上完美运行。

我怀疑这可能是导致此问题的原因,但不确定。

PS:显示两者之间的区别。 Difference between two

堆栈跟踪:

    Program terminated with signal SIGSEGV, Segmentation fault.
#0 0xd0bded2c in std::locale::operator=(std::locale const&) () from /opt/freeware/lib/libstdc++.a(libstdc++.so.6)
(gdb) bt
#0 0xd0bded2c in std::locale::operator=(std::locale const&) () from /opt/freeware/lib/libstdc++.a(libstdc++.so.6)
#1 0xd0bdeee0 in std::ios_base::_M_init() () from /opt/freeware/lib/libstdc++.a(libstdc++.so.6)
#2 0xd0bdede4 in std::basic_ios<char, std::char_traits<char> >::init () from /opt/freeware/lib/libstdc++.a(libstdc++.so.6)
#3 0x100b618c in Logging::Logging (this=0x20086438, filename=..., level=4) at Logging.cpp:404
#4 0x1005d96c in main (argc=<error reading variable>, argv=<error reading variable>) at _start_ :141
warning: (Internal error: pc 0x100001e3 in read in psymtab, but not in symtab.)

warning: (Internal error: pc 0x100001e4 in read in psymtab, but not in symtab.)

代码快照:

string logFile = "test.txt"
Logging* logger = new Logging(logFile,4);

// Logging Constructor
Logging::Logging(const string &filename,loglevel): logfilename(filename),level(loglevel) {
}

最佳答案

我刚刚遇到了同样的问题,并且能够通过在 g++ 编译器的 makefile 中禁用优化标志(如 -O2)来解决这个问题。我的 makefile 包含

CC = g++
CC_FLAGS = -g3 -ggdb -Wall -std=c++11 -DDEBUG -pthread -O2

显示来自 gdb 的回溯 std::locale::operator=(std::locale const&) ()

如果没有标志“-O2”,这将不再发生

CC = g++
CC_FLAGS = -Wall -std=c++11 -DDEBUG -pthread

关于c++ - AIX 上的 std::locale::operator=(std::locale const&) 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43490185/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com