stlstring, multiprocessors and multithreads

Last week, a coworker had a problem in execution time in her program. This program is multithread, uses 5 seconds timers and worked very well until this time. The difference… it was running in other linux box with two dual-core cpus.

As we could see, it broke after 25 executions (more or less) of the timer function. The core showed a backtrace of allocating memory in a string assigment. The output said that there were a problem with “corrupted double linked list”.

We used gdb to know what was wrong, I have the same output and similar backtrace but each time in different places of the source code. However, we tried running this program on valgrind because we found out that could be a freeing memory problem but… the program runned well! Amazing!

We started to read the source code searching any kind of error with the freeing dynamic memory code… with no result.

Finally, we found out a problem with the stlstring library… It’s unable to run in multithread programs in… multiprocessors boxes! After substituting all the stlstrings with char* and praying for not doing any errors, the program have runned smoothly since then.

PD: It appears that worked in valgrind because it simulates a mono-processor cpu.

CC BY-SA 4.0 This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

One thought on “stlstring, multiprocessors and multithreads

Comments are closed.