Very intermittent segmentation fault with boost::multiprecision

tjisana (泰志) via Boost-users <[email protected]>
Newsgroups gmane.comp.lib.boost.user
Message-ID <CAGXaPtD3rCbiowqUe0tSUus+a_LnfhVBrWyPm_itE2ybHzGhWg@mail.gmail.com>
Team,

Trying to get to the root of a very intermittent seg fault in my program.
Here's the snipped (not able to reproduce) as the section of code is part
of a callback and I'm not sure how to reproduce it.  Here's the tickPrice
method and the trace from gdb is below that ... any thoughts?


TJ

void ib_trading_engine::tickPrice(TickerId tickerId, TickType field, double
price, const TickAttrib& attribs) {
this -> current_time();
ticksnapshot_complete_ = false;

last_tick spy_call_trade;
last_tick spy_put_trade;
last_tick qqq_call_trade;
last_tick qqq_put_trade;

spy_call_trade.contract(spy_call_contract_);
spy_call_trade.datetime(local_time_);
spy_call_trade.symbol(spy_call_symbol_);

spy_put_trade.contract(spy_put_contract_);
spy_put_trade.datetime(local_time_);
spy_put_trade.symbol(spy_put_symbol_);

qqq_call_trade.contract(qqq_call_contract_);
qqq_call_trade.datetime(local_time_);
qqq_call_trade.symbol(qqq_call_symbol_);

qqq_put_trade.contract(qqq_put_contract_);
qqq_put_trade.datetime(local_time_);
qqq_put_trade.symbol(qqq_put_symbol_);

try {
if (tickerId == 1001 && field == TickType::LAST) {
spy_strike_ = (unsigned int)std::trunc(price);
ticksnapshot_complete_ = true;

last_spy_price_ = bmp::cpp_dec_float_50(price);
}

else if (tickerId == 1002) {
switch (field) {
case TickType::BID: last_call_bid_ = bmp::cpp_dec_float_50(price);
break;
case TickType::ASK: last_call_ask_ = bmp::cpp_dec_float_50(price);
break;
case TickType::LAST: spy_call_trade.last(bmp::cpp_dec_float_50(price));
trade_queue_.push(spy_call_trade);
break;
default:
break;
}
}

else if (tickerId == 1003) {
switch (field) {
case TickType::BID: last_put_bid_ = bmp::cpp_dec_float_50(price);
break;
case TickType::ASK: last_put_ask_= bmp::cpp_dec_float_50(price);
break;
case TickType::LAST: spy_put_trade.last(bmp::cpp_dec_float_50(price));
trade_queue_.push(spy_put_trade);
break;
default:
break;
}
}

else if (field == TickType::LAST && tickerId == 2001) {
qqq_strike_ = (unsigned int)std::trunc(price);
ticksnapshot_complete_ = true;

last_qqq_price_ = bmp::cpp_dec_float_50(price);
}

else if (tickerId == 2002) {
switch (field) {
case TickType::BID: last_call_bid_ = bmp::cpp_dec_float_50(price);
break;
case TickType::ASK: last_call_ask_ = bmp::cpp_dec_float_50(price);
break;
case TickType::LAST: qqq_call_trade.last(bmp::cpp_dec_float_50(price));
trade_queue_.push(qqq_call_trade);
break;
default:
break;
}
}

else if (tickerId == 2003) {
switch (field) {
case TickType::BID: last_put_bid_ = bmp::cpp_dec_float_50(price);
break;
case TickType::ASK: last_put_ask_= bmp::cpp_dec_float_50(price);
break;
case TickType::LAST: qqq_put_trade.last(bmp::cpp_dec_float_50(price));
trade_queue_.push(qqq_put_trade);
break;
default:
break;
}
}
}

catch (const std::exception& exception) {
std::cerr << "ib_trading_engine::tickPrice() exception: " <<
exception.what() << "\n";
}
}

Core was generated by `./atm_call_paper_2.1'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00000000004221fd in
boost::multiprecision::backends::cpp_dec_float<50u, int, void>::pow2 (p=30)
at /usr/include/boost/multiprecision/cpp_dec_float.hpp:2936
2936   cpp_dec_float<Digits10, ExponentType, Allocator> t;
[Current thread is 1 (Thread 0x7fc4418027c0 (LWP 20245))]
(gdb) bt
#0  0x00000000004221fd in
boost::multiprecision::backends::cpp_dec_float<50u, int, void>::pow2 (p=30)
at /usr/include/boost/multiprecision/cpp_dec_float.hpp:2936
#1  0x00000000004157ba in
boost::multiprecision::backends::cpp_dec_float<50u, int,
void>::operator=<double> (this=0x7fc440fe2f40, a=2.9500000000000002) at
/usr/include/boost/multiprecision/cpp_dec_float.hpp:2290
#2  0x0000000000411c17 in
boost::multiprecision::backends::cpp_dec_float<50u, int,
void>::cpp_dec_float<double>(double,
std::enable_if<std::is_floating_point<double>::value&&(!std::is_same<double,
__float128>::value), void>::type*) (this=0x7fc440fe2f40,
    val=2.9500000000000002) at
/usr/include/boost/multiprecision/cpp_dec_float.hpp:249
#3  0x000000000040fcb6 in
boost::multiprecision::number<boost::multiprecision::backends::cpp_dec_float<50u,
int, void>,
(boost::multiprecision::expression_template_option)1>::number<double>(double
const&,
std::enable_if<std::is_convertible<boost::multiprecision::detail::canonical<double,
boost::multiprecision::backends::cpp_dec_float<50u, int, void> >::type,
boost::multiprecision::backends::cpp_dec_float<50u, int, void>
>::value&&(!boost::multiprecision::detail::is_restricted_conversion<boost::multiprecision::detail::canonical<double,
boost::multiprecision::backends::cpp_dec_float<50u, int, void> >::type,
boost::multiprecision::backends::cpp_dec_float<50u, int, void> >::value),
void>::type*) (this=0x7fc440fe2f40, v=@0x7fc440fe1d60: 2.9500000000000002)
at /usr/include/boost/multiprecision/number.hpp:64
#4  0x0000000000447332 in ib_trading_engine::tickPrice (this=0x1dd0650,
tickerId=1002, field=BID, price=2.9500000000000002, attribs=...) at
../src/ib_trading_engine.cpp:700
#5  0x000000000049c5c4 in EDecoder::processTickPriceMsg (this=0x1dd30c0,
ptr=0x7fc43c0077a6 "00%", endPtr=0x7fc43c0077a6 "00%") at
../src/client/EDecoder.cpp:65
#6  0x00000000004a7ea6 in EDecoder::parseAndProcessMsg (this=0x1dd30c0,
beginPtr=@0x7fc440fe33e8: 0x7fc43c007790 "1", endPtr=0x7fc43c0077a6 "00%")
at ../src/client/EDecoder.cpp:2247
#7  0x00000000004bee93 in EReader::processMsgs (this=0x1dd30b0) at
../src/client/EReader.cpp:282
#8  0x0000000000444630 in ib_trading_engine::process_messages
(this=0x1dd0650) at ../src/ib_trading_engine.cpp:405
#9  0x000000000044465f in ib_trading_engine::current_time (this=0x1dd0650)
at ../src/ib_trading_engine.cpp:410
#10 0x0000000000447086 in ib_trading_engine::tickPrice (this=0x1dd0650,
tickerId=1002, field=BID, price=2.96, attribs=...) at
../src/ib_trading_engine.cpp:666

_______________________________________________
Boost-users mailing list
[email protected]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.