- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 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 function
Anyone has some inkling on how to understand what's going on or has experienced something similar?
Many Thanks
Best regards
Dario
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page