Skip to content

Commit

Permalink
Use UBSan for release builds (#1733)
Browse files Browse the repository at this point in the history
* Always build with UBSan
* Disable some advanced UBSan sub-options
... not recognized by GCC 8.1
* Use GCC 7.3 compatible option for USan
* Allow global TRIK_SANITIZE_UNDEFINED_FLAGS
* Add UbSan for Windows and rename main.yml to windows_build_with_installer.yml
  • Loading branch information
iakov authored Jul 30, 2024
1 parent 63e13e7 commit 381ac5b
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: GHA CI
name: Windows build
on:
push:
branches-ignore:
Expand Down Expand Up @@ -138,7 +138,7 @@ jobs:
timeout-minutes: 1
run: |
cd ${{ env.BUILD_DIR }}
qmake $GITHUB_WORKSPACE/studio.pro -spec win32-g++ CONFIG+=release CONFIG+=tests CONFIG+=noPch PYTHON_PATH="${pythonLocation}" # CONFIG+=silent
qmake $GITHUB_WORKSPACE/studio.pro -spec win32-g++ CONFIG+=release CONFIG+=sanitizer CONFIG+=sanitize_undefined CONFIG+=tests CONFIG+=noPch PYTHON_PATH="${pythonLocation}" # CONFIG+=silent
- name: QMake all
timeout-minutes: 5
Expand Down
42 changes: 24 additions & 18 deletions global.pri
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ equals(TEMPLATE, lib) {
CONFIG += sanitizer
}

unix:!nosanitizers {
!nosanitizers {

# seems like we want USan always, but are afraid of ....
!CONFIG(sanitize_address):!CONFIG(sanitize_thread):!CONFIG(sanitize_memory):!CONFIG(sanitize_kernel_address) {
Expand All @@ -143,20 +143,25 @@ unix:!nosanitizers {


#LSan can be used without performance degrade even in release build
#But at the moment we can not, because of Qt problems
!macx-clang:CONFIG(debug):!CONFIG(sanitize_address):!CONFIG(sanitize_memory):!CONFIG(sanitize_thread) { CONFIG += sanitize_leak }
#But at the moment we can not, because of Qt and MinGW problems
!win32:!macx-clang:CONFIG(debug):!CONFIG(sanitize_address):!CONFIG(sanitize_memory):!CONFIG(sanitize_thread) { CONFIG += sanitize_leak }

sanitize_leak {
QMAKE_CFLAGS += -fsanitize=leak
QMAKE_CXXFLAGS += -fsanitize=leak
QMAKE_LFLAGS += -fsanitize=leak
QMAKE_CFLAGS *= -fsanitize=leak
QMAKE_CXXFLAGS *= -fsanitize=leak
QMAKE_LFLAGS *= -fsanitize=leak
}

sanitize_undefined:macx-clang {
# sometimes runtime is missing in clang. this hack allows to avoid runtime dependency.
#QMAKE_SANITIZE_UNDEFINED_CFLAGS += -fsanitize-trap=undefined
#QMAKE_SANITIZE_UNDEFINED_CXXFLAGS += -fsanitize-trap=undefined
#QMAKE_SANITIZE_UNDEFINED_LFLAGS += -fsanitize-trap=undefined
sanitize_undefined {
#TRIK_SANITIZE_UNDEFINED_FLAGS += \
#-fsanitize=undefined,float-divide-by-zero,unsigned-integer-overflow,implicit-conversion,local-bounds

# This hack allows to avoid runtime dependency.
win32:isEmpty(TRIK_SANITIZE_UNDEFINED_FLAGS):TRIK_SANITIZE_UNDEFINED_FLAGS = -fsanitize-undefined-trap-on-error

QMAKE_SANITIZE_UNDEFINED_CFLAGS *= $$TRIK_SANITIZE_UNDEFINED_FLAGS
QMAKE_SANITIZE_UNDEFINED_CXXFLAGS *= $$TRIK_SANITIZE_UNDEFINED_FLAGS
QMAKE_SANITIZE_UNDEFINED_LFLAGS *= $$TRIK_SANITIZE_UNDEFINED_FLAGS
}

sanitize_memory {
Expand All @@ -165,15 +170,16 @@ unix:!nosanitizers {

}

unix {
QMAKE_CFLAGS_RELEASE += -fsanitize-recover=all
QMAKE_CXXFLAGS_RELEASE += -fsanitize-recover=all

QMAKE_CFLAGS_RELEASE += -fsanitize-recover=all
QMAKE_CXXFLAGS_RELEASE += -fsanitize-recover=all
QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -fno-sanitize-recover=all
QMAKE_CXXFLAGS_RELEASE_WITH_DEBUGINFO += -fno-sanitize-recover=all

QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -fno-sanitize-recover=all
QMAKE_CXXFLAGS_RELEASE_WITH_DEBUGINFO += -fno-sanitize-recover=all

QMAKE_CFLAGS_DEBUG += -fno-sanitize-recover=all
QMAKE_CXXFLAGS_DEBUG += -fno-sanitize-recover=all
QMAKE_CFLAGS_DEBUG += -fno-sanitize-recover=all
QMAKE_CXXFLAGS_DEBUG += -fno-sanitize-recover=all
}
}

OBJECTS_DIR = .build/$$CONFIGURATION/obj
Expand Down
2 changes: 1 addition & 1 deletion plugins/robots/thirdparty/trikRuntime/trikRuntime
Submodule trikRuntime updated 59 files
+13 −3 .github/dependabot.yml
+10 −8 .github/workflows/main.yml
+23 −24 .github/workflows/rockylinux.yml
+154 −0 .github/workflows/trik-toolchain.yml
+3 −0 README.md
+6 −3 azure-pipelines.yml
+1 −1 deploy.sh
+17 −22 global.pri
+1 −1 qslog/QsLogSharedLibrary.pro
+2 −2 scripts/azure/install_Linux.sh
+1 −1 tests/thirdparty/googletest
+1 −1 tests/thirdparty/googletest.pri
+1 −1 tests/thirdparty/googletest.pro
+52 −0 translations/ADDING_TRANSLATIONS.en.md
+0 −1 translations/fr/locale.ini
+0 −44 translations/fr/trikKernel_fr.ts
+0 −43 translations/fr/trikRun_fr.ts
+0 −33 translations/fr/trikScriptRunner_fr.ts
+0 −1 translations/ru/locale.ini
+0 −46 translations/ru/trikKernel_ru.ts
+0 −48 translations/ru/trikRun_ru.ts
+0 −33 translations/ru/trikScriptRunner_ru.ts
+10 −13 translations/translations.pro
+700 −0 translations/trikRuntime_de.ts
+186 −137 translations/trikRuntime_fr.ts
+189 −133 translations/trikRuntime_ru.ts
+4 −0 translations/trikRuntime_sample.ts
+1 −1 trikCommunicator/trikCommunicator.pro
+6 −6 trikControl/configs/kernel-3.6/system-config.xml
+12 −2 trikControl/include/trikControl/pwmCaptureInterface.h
+20 −0 trikControl/src/configurerHelper.cpp
+8 −0 trikControl/src/configurerHelper.h
+1 −1 trikControl/src/event.cpp
+1 −1 trikControl/src/moduleLoader.h
+44 −2 trikControl/src/pwmCapture.cpp
+15 −2 trikControl/src/pwmCapture.h
+1 −1 trikControl/trikControl.pro
+1 −2 trikControl/trikControlExport.pri
+17 −11 trikGui/languageSelectionWidget.cpp
+63 −0 trikGui/pwmCaptureIndicator.cpp
+54 −0 trikGui/pwmCaptureIndicator.h
+4 −0 trikGui/sensorsWidget.cpp
+1 −0 trikGui/sensorsWidget.h
+10 −0 trikGui/startWidget.cpp
+5 −7 trikGui/trikGui.pro
+2 −2 trikHal/trikHal.pro
+5 −20 trikKernel/include/trikKernel/exceptions/trikRuntimeException.h
+30 −12 trikKernel/include/trikKernel/timeVal.h
+0 −41 trikKernel/src/timeVal.cpp
+6 −6 trikKernel/src/translationsHelper.cpp
+5 −6 trikKernel/trikKernel.pro
+1 −1 trikNetwork/trikNetwork.pro
+1 −5 trikRun/trikRun.pro
+22 −17 trikRuntime.pro
+1 −0 trikScriptRunner/include/trikScriptRunner/trikScriptRunnerInterface.h
+3 −1 trikScriptRunner/src/pythonEngineWorker.cpp
+1 −5 trikScriptRunner/trikScriptRunner.pro
+1 −1 trikServer/trikServer.pro
+1 −1 trikWiFi/trikWiFi.pro
6 changes: 4 additions & 2 deletions plugins/robots/thirdparty/trikRuntime/trikRuntime.pro
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ TEMPLATE = subdirs
include(../../../../global.pri)

SUBDIRS += \
trikRuntimeQsLog \
trikKernel \
trikNetwork \
trikControl \
Expand All @@ -26,7 +27,7 @@ SUBDIRS += \

tests {
SUBDIRS *= tests
tests.depends = trikScriptRunner trikCommunicator trikKernel
tests.depends = trikScriptRunner trikCommunicator trikKernel trikRuntimeQsLog
tests.subdir = $$PWD/trikRuntime/tests
}

Expand All @@ -43,8 +44,9 @@ trikNetwork.subdir = $$PWD/trikRuntime/trikNetwork
trikControl.subdir = $$PWD/trikRuntime/trikControl
translations.subdir = $$PWD/trikRuntime/translations
trikHal.subdir = $$PWD/trikRuntime/trikHal
trikRuntimeQsLog.file = $$PWD/trikRuntime/qslog/QsLogSharedLibrary.pro
trikControl.depends = trikKernel trikHal
trikKernel.depends =
trikKernel.depends = trikRuntimeQsLog
trikNetwork.depends = trikKernel
trikScriptRunner.depends += trikControl trikKernel trikNetwork
trikHal.depends = trikKernel
Expand Down

0 comments on commit 381ac5b

Please sign in to comment.