Undefined behavior in topaz app

Discussions on installation issues go here.
Posts: 35
Joined: 01 Mar 2012, 16:51

Undefined behavior in topaz app

Postby jamesjer » 07 Nov 2023, 16:16

The Fedora project builds packages with -D_GLIBCXX_ASSERTIONS. One of the assertions failed while running the polymake 4.11 test suite. In apps/topaz/src/barycentric_subdivision.cc, line 142, description.back() is called. However, during test suite execution at least, description can be empty. Calling back() on an empty string invokes undefined behavior. Please check that description.empty() is false before calling description.back(). (And thank you again for the 4.11 release!)

Posts: 140
Joined: 10 Jan 2011, 17:21

Re: Undefined behavior in topaz app

Postby blorenz » 07 Nov 2023, 16:57

Thanks for the report, I have fixed this for our master branch.
I am slightly surprised that this did not trigger the sanitizer build in our CI, but I will check if we can add _GLIBCXX_ASSERTIONS to one of the builds.


Code: Select all

- if (description.back() != '\n') + if (description.empty() || description.back() != '\n')

User avatar
Main Author
Posts: 424
Joined: 25 Dec 2010, 17:40

Re: Undefined behavior in topaz app

Postby gawrilow » 14 Nov 2023, 12:00

We are running the sanitizer in the configuration with libc++ from LLVM, where std::string has a small internal buffer for short strings (up to 6 bytes) overlapping with the pointer to heap-allocated long strings. This way, from the low-level perspective, the last character is always well-allocated and even initialized (with 0).

Return to “Installing polymake”