Skip to content

armgit / laya

Public Imported from GitHub
0

Non-autoregressive System 1 decision engine. Typed choice, score and yes/no decisions over any text in a single forward pass, in 100+ languages, with a router that picks the right checkpoint per request.

ci(cpp): TSan cannot read the prebuilt ONNX Runtime, so stop reporting it

Nandakishor7fa53b3ebe67
diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml
index 9bfba099..37b1fd92 100644
--- a/.github/workflows/cpp.yml
+++ b/.github/workflows/cpp.yml
@@ -225,6 +225,15 @@ jobs:
env:
LAYA_ONNX_GRAPH: ${{ env.ONNX_ROOT }}/multilingual/laya.onnx
LAYA_ONNX_GRAPH_ENGLISH: ${{ env.ONNX_ROOT }}/english/laya.onnx
+ # The ONNX Runtime this links is a prebuilt binary, so TSan cannot see the
+ # synchronization inside it and reads every buffer its thread pool returns as a race.
+ # laya-cpp/tsan-onnxruntime.supp records the measurement and what the suppression costs.
+ # Unused by the g++/debug and clang++/asan-ubsan cells, which link no TSan runtime to
+ # read it. An absolute path on purpose: TSan aborts the process with exit 134 on a
+ # suppressions file it cannot read, so a path relative to the wrong directory would take
+ # out every test rather than fail quietly. Inherited by laya_onnx_static_holder, whose
+ # exit status AStaticSessionAndAgentExitCleanly asserts and which TSan leaves at 66.
+ TSAN_OPTIONS: suppressions=${{ github.workspace }}/laya-cpp/tsan-onnxruntime.supp
run: ctest --preset "${{ matrix.preset }}" --output-junit "$RUNNER_TEMP/ctest-onnx.xml"
- name: Count tests (fail on skip, enforce the onnx floor)
if: ${{ !cancelled() }}
diff --git a/laya-cpp/tsan-onnxruntime.supp b/laya-cpp/tsan-onnxruntime.supp
new file mode 100644
index 00000000..79cecbb2
--- /dev/null
+++ b/laya-cpp/tsan-onnxruntime.supp
@@ -0,0 +1,24 @@
+# ThreadSanitizer suppressions for the prebuilt ONNX Runtime.
+#
+# laya-cpp links the official ONNX Runtime binary that cmake/onnxruntime.cmake downloads and
+# sha256-verifies. That library is not built with -fsanitize=thread, so TSan cannot see its
+# internal synchronization: the happens-before edges its own mutexes and atomics establish are
+# invisible, and every buffer its intra-op thread pool hands back to the main thread therefore
+# looks like an unsynchronized access.
+#
+# Measured, not assumed: the `onnx (clang++, tsan)` job reported 342 races, every single one with
+# a libonnxruntime.so frame, and all of them in `memcpy` or `operator delete`. 20 of 479 tests
+# failed as a result, including four that only assert the static-holder helper's exit status and
+# saw TSan's own exitcode=66.
+#
+# Scope, and what it costs. `called_from_lib` drops a report only when the accessing stack runs
+# inside this library, so a race between two laya threads on laya-owned state is still reported.
+# What it does give up is a race where laya hands memory to an ONNX Runtime worker thread, since
+# that thread's stack is inside the library. TSan cannot adjudicate those either way while the
+# library is uninstrumented, so the choice is between suppressing them and switching the whole
+# cell off; this keeps the laya-vs-laya coverage the cell exists for, which is what
+# OnnxRig.ConcurrentPredictAgreesWithASerialCall and CloseInterruptsARunInFlight exercise.
+#
+# Revisit if ONNX Runtime ever ships a TSan-instrumented build, or if laya starts passing a
+# callback into the library.
+called_from_lib:libonnxruntime.so