Open MarkCRay opened 3 months ago
Thanks for this. I'll spend some time this weekend looking into it and get back to you! How does changing the sleep time / int distribution range affect this (if at all?)
In Trader.cpp for Trader::doAction(), if I change the SleepDuration from 3 to 20 seconds, then it coredumps in 20 secords or a multiple of 20 seconds, or if I change it to 2, then it coredumps in 2 seconds or some multiple of 2 seconds.
From the stack trace, it would see to originate from the Order Cancellation code:
else{
std::uniform_int_distribution<int> orderCancelDistribution(0, active_orders.size()-1);
choice = orderCancelDistribution(generator);
if(!(active_orders.size() == 0)){
cancelOrder(active_orders[choice], trademtx);
}
}
}
But even if I comment this out, it still coredumps somewhere else where uniform_int_distribution is used.
Documentation said it was developed on MacOS, but I thought I would try on Linux. I'm certainly not an expert on C++ programming.
OS: Red Hat Enterprise Linux release 8.2 Kernel Version: 4.18.0-193.14.3.el8_2.x86_64 Processor model: Intel(R) Xeon(R) CPU E5-2680 v3 @ 2.50GHz gcc version 8.3.1 20191121 (Red Hat 8.3.1-5) (GCC)
I compiled the program as follows:
$ g++ -g -std=c++17 -pthread *.cpp -o main.exe
The program starts up and runs, but core dumps after ~3 seconds. The amount of time is variable, but its always a multiple of 3 seconds. I think this is because the Trader thread wakes up every 3 seconds. Below is a typical run...
real 0m3.047s user 0m0.012s sys 0m0.047s
GDB on the core dump shows
The stack trace of the thread seems to show a recursive loop in uniform_int_distribution. Note the depth of the trace shows over 52K stack frames. This is with a stack size of 8192K. I can increase the stack size, but the coredump still occurs, there just more stack frames on the stack.