Skip to content

UBSAN testing for Chapel #28229

@jabraham17

Description

@jabraham17

While authoring #28227, I ran Chapel with CHPL_SANITIZE_EXE=undefined and also just did compiles with chpl --ccflags=-fsanitize=undefined --ldflags=-fsanitize=undefined. This was invaluable in finding the bug and fixing it, but I noticed a ton of other ubsan errors.

For example, the following code can result in C undefined behavior, because we end up with code like (uint64_t)0-(uint64_t)1, which is UB

for i in 0..#0 { }

There were many other errors, and I actually got different sets of errors when using CHPL_TARGET_COMPILER=clang vs CHPL_TARGET_COMPILER=gnu.

This makes me want to go through and clean up all of this UB, and then lock it in with nightly tests for both clang and gnu (just like we do with asan already). In my opinion, these are all bugs waiting to happen, and I want to be proactive about fixing them.

At the bare minimum, I've opened https://github.com/chapel-lang/chapel/pull/28228/changes to document this tool for others to use in the future.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions