Segmentation error only when working on multi-core

I use the C ++ library, which is designed for multi-threaded processing, and the number of worker threads can be set using a variable. The library uses pthreads. The problem occurs when I run the application, which is provided as a test library, on a quad-core computer using 3 threads or more. The application terminates with a segmentation failure time error. When I try to insert some "cout" traces in some parts of the library, the problem is resolved and the application ends normally. When working on a single-core computer, no matter how many threads are used, the application ends normally.

How can I find out where the seam problem is?

Is this some kind of sync error? how can i find it? is there any tool i can use also check the code?

+3
source share
3 answers

It looks like you are using Linux (you mention pthreads). Have you considered running valgrind ?

Valgrind has tools for checking data race conditions (helgrind) and memory problems (memcheck). Valgrind can find such an error in debug mode without having to create a crash that creates release mode.

+2
source

Some general debugging tips.

  • , ( -g). (.. ).
  • , , seg. , (ulimit -c unlimited), / ​​ (gdb/path/to/prog/path/to/core), , , , .
0

.
.
, , , .

You want to create a kernel file; then debug the application using the main file. This will set the debugger to the state of the application at the time of its breaking. This will allow you to check variables / registers etc.

How to do this will be very dependent on your system.

A quick google showed the following:

http://www.codeguru.com/forum/archive/index.php/t-299035.html

Hope this helps.

0
source

Source: https://habr.com/ru/post/1723074/


All Articles