Multi-threading can cause hard-to-diagnose problems and they are especially visible on multi-core CPUs (or multi-CPU systems) where threads actually run concurrently.

Here's a quick way to find out if the segfaults you are experiencing might be due to some concurrency/locking problem: force the application to run on a single CPU using schedtool (part of the schedtool package on Debian/Ubuntu).

schedtool -a 0 -e applicationname

This is just one example of what you can do with the CPU Affinity controls on Linux.

taskset (from util-linux) can do that too.
Comment by bgoglin