I'm quite puzzled by this one. I have a push_back to a vector that consistently (but only once every few hours) produces a double free crash. This code is only called in a single-threaded context. The docs seem to state that these operations should be safe.
bool ready_to_sell = true;
orders = std::vector<std::string>();
void submit_order(std::string order_id){
// Why is this causing a free issue?
orders.push_back(order_id);
if(ready_to_sell){
ready_to_sell = false;
rdx.publish("SELL",asks.back()); // Redis client
orders = std::vector<std::string>();
} else {
std::cout << "ALREADY SELLING\n";
}
}
Here is part of the leaks/valgrind output showing this is the problem spot - line 7 shows it is the push_back causing the problem.
8 seller 0x100b8c03c submit_order(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) + 44
7 seller 0x100b8a9b8 std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >::push_back(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 72 vector:1661
6 venue_stat_arb 0x100de70bc void std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > >::__construct_one_at_end<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 88 vector:948
Aucun commentaire:
Enregistrer un commentaire