Я получаю coredump при печати ostream-объектов в файле, детали обратной трассировки:
Program terminated with signal SIGSEGV, Segmentation fault
(gdb) bt
#0 0x00000000008e21e6 in std::ostream::sentry::sentry (this=0x7f41fceb4ac0, __os=...) at gcc8_build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/ostream.tcc:46
#1 0x00000000008e2d22 in std::ostream::_M_insert<long> (this=0xf1a238 <fixParserObj+16152>, __v=1581394546) at gcc8_build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/ostream.tcc:63
#2 0x000000000055757f in Stats::printSummary (this=0xf19f98 <fixParserObj+15480>, out=...) at src/include/Stats.h:195
#3 0x0000000000558777 in FixParser::parse (this=0xf16320 <fixParserObj>,
msg=0x7f41fceb4c40 "1581394546.106941334 : 8=FIX.4.2\001\063\064=195316\001\063\065=G\001\061\061=132000256\001\064\061=132000256\001\071\070=0\001\061\060\070=50\001\065\066=NSE\001\066\060=20200211-04:15:46\001\065\064=2\001\064\064=4225\001\063\070=600\001\064\070=80872\001\064\060=2\001\063\067=1300000003406877\001\064\062=1265881521\001\064\063=1265881521721453309\001\061\060=000", msg_size=213)
at src/include/FixParser.hpp:238
#4 0x000000000054b13d in fixReceiver (ipList=..., portList=...) at src/src/main.cc:319
#5 0x000000000054b36c in <lambda()>::operator()(void) const (__closure=0x1de1958) at src/src/main.cc:381
#6 0x000000000054e999 in std::__invoke_impl<void, main(int, char**)::<lambda()> >(std::__invoke_other, <lambda()> &&) (__f=...) at /usr/gcc-8.1/include/c++/8.1.0/bits/invoke.h:60
#7 0x000000000054e58a in std::__invoke<main(int, char**)::<lambda()> >(<lambda()> &&) (__fn=...) at /usr/gcc-8.1/include/c++/8.1.0/bits/invoke.h:95
#8 0x000000000054f024 in std::thread::_Invoker<std::tuple<main(int, char**)::<lambda()> > >::_M_invoke<0>(std::_Index_tuple<0>) (this=0x1de1958) at /usr/gcc-8.1/include/c++/8.1.0/thread:234
#9 0x000000000054efe0 in std::thread::_Invoker<std::tuple<main(int, char**)::<lambda()> > >::operator()(void) (this=0x1de1958) at /usr/gcc-8.1/include/c++/8.1.0/thread:243
#10 0x000000000054efa4 in std::thread::_State_impl<std::thread::_Invoker<std::tuple<main(int, char**)::<lambda()> > > >::_M_run(void) (this=0x1de1950) at /usr/gcc-8.1/include/c++/8.1.0/thread:186
#11 0x00000000008862df in execute_native_thread_routine () at ../../../../../gcc-8.1.0/libstdc++-v3/src/c++11/thread.cc:80
#12 0x00007f41fe8606db in start_thread (arg=0x7f41fceb6700) at pthread_create.c:463
#13 0x00007f41fe1eb88f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
(gdb) f 2
#2 0x000000000055757f in Stats::printSummary (this=0xf19f98 <fixParserObj+15480>, out=...) at src/include/Stats.h:195
195 src/include/Stats.h: No such file or directory.
(gdb) p out
$1 = (std::ostream &) @0xf1a238: {
<std::basic_ios<char, std::char_traits<char> >> = <invalid address>,
members of std::basic_ostream<char, std::char_traits<char> >:
_vptr.basic_ostream = 0x3132300000eccd50
}
Код Stats.h
void printSummary(std::ostream &out = std::cout){
.....
out << m_current.tv_sec << "," << lastHbtTime << "," << maxOrderPerSlidingSec << "," << totalActiveOrders << endl;
----
}
FixParser. cpp
std::ofstream statsFile;
std::string fname = "fix_" + gConfig["colo_ip"] +"_" + getToday();
statsFile.open(fname, std::ios::app | std::ios::out);
......
..
printSummary(statsFile);
....
..
Я не могу решить эту проблему с дампом ядра, если кто-то может помочь, это было бы здорово, Если я попробую std::cout
, код работает отлично.