Intel® oneAPI DPC++/C++ Compiler
Talk to fellow users of Intel® oneAPI DPC++/C++ Compiler and companion tools like Intel® oneAPI DPC++ Library, Intel® DPC++ Compatibility Tool, and Intel® Distribution for GDB*
789 Discussions

Intel DPC++ 2025 compiles a crashing release version of a Eigen based algorithm

DarioZ
Beginner
2,640 Views

Hello,

the following somewhat involuted function is an extract of a larger meshing algorithm which exhibits a crash for a memory access violation only when compiled in release with intel dpc++ 2025 (visual studio 2022, windows 11). No crash happens using MSVC with or without release optimizations.

I managed to reproduce the crash in the attached visual studio solution with minimum data (Eigen being header only is included as well). The function seems correct and in no case should perform out of bounds accesses or have data races. Inserting a simple if statement in the lambda used to compare elements will avoid the crash, even when the if statement won't ever evaluate to true.

    static constexpr std::size_t NCOLS = 32;
    static constexpr std::size_t IDXTEST = 11;
    //NCOLS columns, values do not seem to really matter, but they have to be different, setting them all to ones
    //won't result in any exceptions.    
    MatrixXf O_new;
    O_new.resize(3, NCOLS);
    O_new.setRandom();
    //NCOLS vectors each with two elements referrring the (IDXTEST+1)-th column in O_new
    std::vector<std::vector<std::uint32_t> > adj_new{ (std::size_t)NCOLS , {IDXTEST, IDXTEST} };
    tbb::parallel_for(
        tbb::blocked_range<uint32_t>(0u, (uint32_t)O_new.cols()),
        [&](const tbb::blocked_range<uint32_t>& range) {
            for (uint32_t i = range.begin(); i != range.end(); ++i) {
                //changing s and t could avoid the crash.
                Vector3f s{ -0.221550092,-0.690182805,0.0413681120 },
                    t{ -0.183548957,0,-0.983010530 }, p = O_new.col(i);
                //sort adj_new[i] according to the values it refers in O_new
                //j0 and j1 always IDXTEST -> The two atans return values are always equal
                //-> Sort on two elements with the same values
                std::sort(adj_new[i].begin(), adj_new[i].end(),
                    [&](const std::uint32_t& j0, const std::uint32_t& j1) {
                        //any if statement here will cause the parallel_for to terminate
                        //without any exceptions. Disabling optimizations has the same result.
                        //if (i == 9999)
                        //    std::cout << "bye";
                        Vector3f v0 = O_new.col(j0) - p, v1 = O_new.col(j1) - p;
                        return std::atan2(t.dot(v0), s.dot(v0)) > std::atan2(t.dot(v1), s.dot(v1));
                    }
                );
            }
        }
    );

The crash shows the following callstack

memory access violation exceptionmemory access violation exception

Inserting the commented-out if statement at line 28 make the generated assembly to change quite a lot and it seems to stop generating a multiplication between rax and r13 which causes the access violation:

optimized lamba compare functionoptimized lamba compare function

 

Anyone has some inkling on how to understand what's going on or has experienced something similar?

 

Many Thanks

Best regards

Dario

0 Kudos
3 Replies
yzh_intel
Moderator
2,416 Views

Hi, I reproduced your issue, and the problem seems to be in the vectorizing optimizations. I have escalated the issue to compiler team and will get back later once there's any update. 

0 Kudos
yzh_intel
Moderator
1,867 Views

Hi, Not sure if you're still facing this issue, here's a workaround that fixed the issue on my side, could you try option /Qno-intel-lib:libsvml ?

0 Kudos
DarioZ
Beginner
1,244 Views

Hi. thanks for the reply, yes we were still facing the issue (for the time being we were using the standard microsoft compiler). I've tried the workaround both in the real application and in the simplified test, now it works! The code stopped crashing immediately.

Thanks again

Best regards

Dario

0 Kudos
Reply