Skip to content

Fix gcc -fsanitize detected problems#4050

Open
BsAtHome wants to merge 1 commit into
LinuxCNC:masterfrom
BsAtHome:fix_sanitizer1
Open

Fix gcc -fsanitize detected problems#4050
BsAtHome wants to merge 1 commit into
LinuxCNC:masterfrom
BsAtHome:fix_sanitizer1

Conversation

@BsAtHome
Copy link
Copy Markdown
Contributor

An issue was detected, while doing unrelated stuff, that required a deeper dive. A sanitizer switch to gcc/g++ revealed more issues when compiled using -fsanitize=undefined,bool,float-cast-overflow (see also #421).

The changes include:

  • Get rid of static char buffers in shcom and use std::string instead. This has effect on several dependent files, which were all adapted and already had FIXME markers at those places.
  • Fix linuxcnc python module where the ini filename storage was changed to std::string previously. However, the python object structure has no C++ constructor semantics. The string must be separately allocated and cannot be a "normal" member. Otherwise it would not be properly initialized.
  • Several off-by-one compiler messages in char buffers were fixed.
  • Guard rcs_print() when a NULL format argument is passed.
  • Compiling with the sanitizer tripped some stack-frame size warnings. These were slightly increased.
  • A char buffer in halcmd was indexed with -1 on continuation search causing an underflow. That eventuality is now guarded against.

There were also unrelated boost::python problems with "maybe-uninitialized" warnings on value extract. However, it was determined that these were false positives (see also #3931).

It may be prudent to run the code base with other -fsanitize options and see the fallout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant