Runtime failures due to LLVM hardening asserts when compiled with LLVM
Open
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 10
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Description
Polytope fails at the run-time when compiled with LLVM because you access elements past the end of arrays.
Program received signal SIGILL, Illegal instruction.
Privileged opcode.
std::__1::vector<double, std::__1::allocator<double> >::operator[][abi:se190107](unsigned long) (this=0x7fffffffe248, __n=1338) at /usr/include/c++/v1/vector:1436
1436 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n < size(), "vector[] index out of bounds");
(gdb) up
#1 0x00000008004b63cd in polytope::MeshEditor<2, double>::cleanMesh (this=0x7fffffffe1f0, cellMap=std::vector of length 279 = {...}, faceMap=std::vector of length 948 = {...}, nodeMap=std::vector of length 669 = {...})
at /usr/ports/science/polytope/work/polytope-0.7.3-18-gcf83206/src/MeshEditor.cc:664
664 std::copy(&mMesh.nodes[Dimension*i], &mMesh.nodes[Dimension*(i+1)], back_inserter(newNodes));
660│ std::vector<RealType> newNodes;
661│ newNodes.reserve(Dimension*nnodes1);
662│ for (unsigned i = 0; i != nnodes0; ++i) {
663│ if (mNodeMask[i] == 1) {
664├─────> std::copy(&mMesh.nodes[Dimension*i], &mMesh.nodes[Dimension*(i+1)], back_inserter(newNodes));
665│ }
666│ }
667│ mMesh.nodes = newNodes;
We had to use this workaround to get rid of these failures:
CXXFLAGS+= -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE # prevent hardening issues with libc++
llvm-19
FreeBSD 15 STABLE
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with LLVM 19 on FreeBSD 15 and inspect src/MeshEditor.cc around line 664 in MeshEditor::cleanMesh. Check the node-mask and mesh-node sizes used by the copy, then verify the runtime no longer fails with libc++ hardening enabled and the workaround is unnecessary.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 42/100