Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 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
14 changes: 14 additions & 0 deletions .github/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ jobs:
xCodeVersion: 16.4
enableSanitizers: true

- template: jobs/macos.yml
parameters:
name: 'macOS_Xcode164_ThreadSanitizer'
vmImage: 'macOS-latest'
xCodeVersion: 16.4
enableThreadSanitizer: true

# iOS
- template: jobs/ios.yml
parameters:
Expand Down Expand Up @@ -124,3 +131,10 @@ jobs:
enableSanitizers: true
CC: clang
CXX: clang++

- template: jobs/linux.yml
parameters:
name: Ubuntu_ThreadSanitizer_clang
enableThreadSanitizer: true
CC: clang
CXX: clang++
Comment thread
bghgary marked this conversation as resolved.
Outdated
14 changes: 11 additions & 3 deletions .github/jobs/linux.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
parameters:
name: ''
enableSanitizers: false
enableThreadSanitizer: false
CC: gcc
CXX: g++

jobs:
- job: ${{parameters.name}}
timeoutInMinutes: 15
${{if eq(parameters.enableThreadSanitizer, true)}}:
timeoutInMinutes: 30
${{else}}:
timeoutInMinutes: 15

pool:
vmImage: ubuntu-latest

variables:
SANITIZER_FLAG: ${{ coalesce(replace(format('{0}', parameters.enableSanitizers), 'True', 'ON'), 'OFF') }}
SANITIZER_FLAG: ${{coalesce(replace(format('{0}', parameters.enableSanitizers), 'True', 'ON'), 'OFF')}}
THREAD_SANITIZER_FLAG: ${{coalesce(replace(format('{0}', parameters.enableThreadSanitizer), 'True', 'ON'), 'OFF')}}

steps:
- script: |
Expand All @@ -23,7 +28,7 @@ jobs:
- script: |
export CC=${{parameters.CC}}
export CXX=${{parameters.CXX}}
cmake -B Build/ubuntu -G Ninja -D CMAKE_BUILD_TYPE=RelWithDebInfo -D ENABLE_SANITIZERS=$(SANITIZER_FLAG) -D CMAKE_C_COMPILER=${{parameters.CC}} -D CMAKE_CXX_COMPILER=${{parameters.CXX}}
cmake -B Build/ubuntu -G Ninja -D CMAKE_BUILD_TYPE=RelWithDebInfo -D ENABLE_SANITIZERS=$(SANITIZER_FLAG) -D ENABLE_THREAD_SANITIZER=$(THREAD_SANITIZER_FLAG) -D CMAKE_C_COMPILER=${{parameters.CC}} -D CMAKE_CXX_COMPILER=${{parameters.CXX}}
displayName: 'Configure CMake'

- script: |
Expand All @@ -34,3 +39,6 @@ jobs:
- script: ./UnitTests
workingDirectory: 'Build/ubuntu/Tests/UnitTests'
displayName: 'Run Tests'
${{if eq(parameters.enableThreadSanitizer, true)}}:
env:
TSAN_OPTIONS: suppressions=$(Build.SourcesDirectory)/.github/tsan_suppressions.txt
Comment thread
bghgary marked this conversation as resolved.
Outdated
6 changes: 4 additions & 2 deletions .github/jobs/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ parameters:
vmImage: ''
xCodeVersion: ''
enableSanitizers: false
enableThreadSanitizer: false

jobs:
- job: ${{parameters.name}}
Expand All @@ -12,15 +13,16 @@ jobs:
vmImage: ${{parameters.vmImage}}

variables:
SANITIZER_FLAG: ${{ coalesce(replace(format('{0}', parameters.enableSanitizers), 'True', 'ON'), 'OFF') }}
SANITIZER_FLAG: ${{coalesce(replace(format('{0}', parameters.enableSanitizers), 'True', 'ON'), 'OFF')}}
THREAD_SANITIZER_FLAG: ${{coalesce(replace(format('{0}', parameters.enableThreadSanitizer), 'True', 'ON'), 'OFF')}}

steps:
- script: |
sudo xcode-select --switch /Applications/Xcode_${{parameters.xCodeVersion}}.app/Contents/Developer
displayName: 'Select Xcode ${{parameters.xCodeVersion}}'

- script: |
cmake -B Build/macOS -G Xcode -D ENABLE_SANITIZERS=$(SANITIZER_FLAG)
cmake -B Build/macOS -G Xcode -D ENABLE_SANITIZERS=$(SANITIZER_FLAG) -D ENABLE_THREAD_SANITIZER=$(THREAD_SANITIZER_FLAG)
displayName: 'Configure CMake'

- task: Xcode@5
Expand Down
17 changes: 17 additions & 0 deletions .github/tsan_suppressions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# ThreadSanitizer suppressions for JsRuntimeHost
#
# These suppress data races internal to third-party libraries that we cannot fix.
# TSan on macOS (JavaScriptCore via Xcode) passes clean — these suppressions are
# only needed for the Ubuntu JSC build (libjavascriptcoregtk).

# JavaScriptCore internal races in libjavascriptcoregtk.
# Races manifest in TSan interceptors (free/malloc/memcpy/close) called from
# JSC's JIT worker threads. function-name suppressions are needed because the
# top frame is a libc interceptor attributed to UnitTests, not libjavascriptcoregtk.
called_from_lib:libjavascriptcoregtk
race:free
race:close
race:memcpy

# JSC signal handler that doesn't save/restore errno
signal:libjavascriptcoregtk
20 changes: 17 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ FetchContent_Declare(AndroidExtensions
EXCLUDE_FROM_ALL)
FetchContent_Declare(arcana.cpp
GIT_REPOSITORY https://github.com/microsoft/arcana.cpp.git
GIT_TAG b9bf9d85fce37d5fc9dbfc4a4dc5e1531bee215a
GIT_TAG 0b9f9b6d761909fbca9d3ab1f2d8ff1c3d25ed3d
EXCLUDE_FROM_ALL)
FetchContent_Declare(asio
GIT_REPOSITORY https://github.com/chriskohlhoff/asio.git
Expand All @@ -36,8 +36,8 @@ FetchContent_Declare(llhttp
URL "https://github.com/nodejs/llhttp/archive/refs/tags/release/v8.1.0.tar.gz"
EXCLUDE_FROM_ALL)
FetchContent_Declare(UrlLib
GIT_REPOSITORY https://github.com/BabylonJS/UrlLib.git
GIT_TAG 880c2575e57ca0b59068ecc4860f185b9970e0ce
GIT_REPOSITORY https://github.com/bghgary/UrlLib.git
GIT_TAG f0002ca5ccffcfcd2aa45f868835029ad4bcd2dd
EXCLUDE_FROM_ALL)
# --------------------------------------------------

Expand Down Expand Up @@ -85,6 +85,11 @@ option(JSRUNTIMEHOST_POLYFILL_TEXTDECODER "Include JsRuntimeHost Polyfill TextDe

# Sanitizers
option(ENABLE_SANITIZERS "Enable AddressSanitizer and UBSan" OFF)
option(ENABLE_THREAD_SANITIZER "Enable ThreadSanitizer" OFF)

if(ENABLE_SANITIZERS AND ENABLE_THREAD_SANITIZER)
message(FATAL_ERROR "ENABLE_SANITIZERS and ENABLE_THREAD_SANITIZER cannot be used together.")
endif()

if(ENABLE_SANITIZERS)
set(ENABLE_RTTI ON CACHE BOOL "" FORCE)
Expand All @@ -111,6 +116,15 @@ if(ENABLE_SANITIZERS)
endif()
endif()

if(ENABLE_THREAD_SANITIZER)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
add_compile_options(-fsanitize=thread -fno-omit-frame-pointer)
add_link_options(-fsanitize=thread)
else()
message(WARNING "ThreadSanitizer not supported on this compiler.")
endif()
endif()

# --------------------------------------------------

if(JSRUNTIMEHOST_TESTS)
Expand Down
Loading