I have a very strange error now arising in a rather massive C ++ application (massive in terms of CPU and RAM usage, as well as code length - more than 100,000 lines). This works on the Sun Solaris 10 dual-core processor. The program subscribes to stock price feeds and displays them on the "pages" configured by the user (the page is a window construction configured by the user - the program allows the user to configure such pages). This program worked without problems until one of the base libraries became multithreaded. Accordingly, the parts of the program that it affected have changed. To my problem.
After about every three executions, the program will segfault at startup. This is not necessarily a tough rule - sometimes it will break three times in a row and then work five times in a row. This is a secret that is interesting (read: painful). It can appear in several ways, but most often what happens is function A calls function B, and when you enter function B, the frame pointer will suddenly be set to 0x000002. Function A:
result_type emit(typename type_trait<T_arg1>::take _A_a1) const { return emitter_type::emit(impl_, _A_a1); }
This is a simple signal implementation. impl_ and _A_a1 are clearly defined in their box on failure. With the actual execution of this instruction, we end the counter 0x000002.
This does not always happen in this function. In fact, this happens in several places, but this is one of the simplest cases that does not leave so much room for errors. Sometimes it happens that a variable distributed over stacks will suddenly sit on garbage memory (always at 0x000002) for no reason. In other cases, the same code will work fine. So my question is, what could hit the stack so badly? What can actually change the value of a frame pointer? Of course, I never heard of this. The only thing I can think of is that you write the boundaries in an array, but I created it with the help of a stack protector, which should come up with any examples of this event. I am also within my stack. I also do not see how another thread can overwrite a variable in the stack of the first thread, since each thread has its own stack (these are all pthreads). I tried building it on a linux machine, and until I get segfaults there, about one out of three times, it will freeze on me.
Peter Wlodarczyk
source share