firstprivate(CppObject) causes segmentation fault

firstprivate(CppObject) causes segmentation fault


I think the OpenMP firstprivate() clause is broken in the Intel C++ Compiler when used with C++ objects. I am running Linux x86-64 (Fedora 20) and I have installed the latest version of the Intel C++ Compiler. My program ( runs fine with both G++ 4.8 and MSVC 2012 but crashes with a segmentation fault (sometimes also 'double free') with icpc. I did some investigation and found that the following code causes the segmentation fault:

PhiCache cache(primes, phiTiny);

#pragma omp parallel for firstprivate(cache) reduction(-: S2) num_threads(threads) schedule(dynamic)
for (int64_t b = c; b < a_1; b++)
{ }

Note that cache object causes a segmentation fault even if it is not used inside the for loop. If I remove firstprivate(cache) then there is no segmentation fault. Also if I disable OpenMP there is no segmentation fault. Below are the member variables of the PhiCache object. Note that PhiCache class does not use new/delete to manage memory.

class PhiCache() {
std::vector<std::vector<uint16_t> > cache_;
const std::vector<int32_t>& primes_;
const PhiTiny& phiTiny_;
int64_t bytes_;

Thanks for your help,

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Hi Kim,

1. As you complain on the compiler issue it is better to post this on the compiler forum, not on the open source runtime forum.

2. Anyway, I tried your program on RHEL 6.2 (don't have Fedora 20 machine), compiled primesieve library and primecount application by the same Intel compiler (Version, and everything works fine for me.  Though I could not use recommended process (configure, make, etc.) because configure ended with error, so I juct called "icpc *.cpp" in the source directory with appropriate options for include files locations.


Leave a Comment

Please sign in to add a comment. Not a member? Join today