Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create sanitizer build mode (Gcc only) #1714

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Note that these are case sensitive!
* linuxathena
- `-PtgtIP`: Specifies where `./gradlew deploy` should try to copy the fat JAR to
- `-Pprofile`: enables JVM profiling
- `-PwithSanitizers`: On Linux, enables `-fsanitize=address,undefined,leak`

If you're cross-compiling, you'll need the wpilib toolchain installed. This can be done via Gradle: for example `./gradlew installArm64Toolchain` or `./gradlew installRoboRioToolchain`

Expand Down
28 changes: 28 additions & 0 deletions run-photonlibpy-to-crash.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

set -ex

# Path to the program
PROGRAM="./photon-lib/build/install/photonlibTest/linuxx86-64/release/lib/photonlibTest"

# Ensure the program exists
if [[ ! -x "$PROGRAM" ]]; then
echo "Error: Program not found or not executable at $PROGRAM"
exit 1
fi

# https://jvns.ca/blog/2018/04/28/debugging-a-segfault-on-linux/
ulimit -c unlimited
sudo sysctl -w kernel.core_pattern=/tmp/core-%e.%p.%h.%t

# Loop to execute the program until it returns a nonzero exit code
while true; do
"$PROGRAM"
EXIT_CODE=$?

if [[ $EXIT_CODE -ne 0 ]]; then
echo "Program exited with nonzero exit code: $EXIT_CODE"
break
fi
done

6 changes: 6 additions & 0 deletions shared/config.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ model {
withType(NativeBinarySpec).all {
nativeUtils.usePlatformArguments(it)
if (it.toolChain instanceof GccCompatibleToolChain) {
println("Hello! " + it)
it.cppCompiler.args << "-Wno-deprecated-enum-enum-conversion"

if (project.hasProperty('withSanitizers')) {
it.cppCompiler.args << "-fsanitize=address,undefined,leak" << "-g"
it.linker.args << "-fsanitize=address,undefined,leak"
}
}
}
}
Expand Down
Loading