Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
6c37f9f
fix: Stream issues
tmathern Aug 25, 2026
a41ddad
fix: Lock managed resource
tmathern Aug 25, 2026
101655c
fix: Warnings in tests
tmathern Aug 25, 2026
78e5d86
WIP 2 (#313)
tmathern Aug 25, 2026
2eaeec0
fix: Notes clean up
tmathern Aug 25, 2026
0edcb35
fix: Clean up comemnts
tmathern Aug 25, 2026
9dfaf87
fix: clean up tests
tmathern Aug 25, 2026
c8cdb15
ci: Merge remote-tracking branch 'refs/remotes/origin/mathern/sigsev-…
tmathern Aug 26, 2026
e80b039
fix: with_fragment has issues too
tmathern Aug 26, 2026
099c82e
fix: Reorder to avoid potential deadlock
tmathern Aug 26, 2026
a59f06b
Update iterations count in baseline.json
tmathern Aug 26, 2026
aa605af
fix: Error handling
tmathern Aug 26, 2026
e53294a
ci: Merge remote-tracking branch 'refs/remotes/origin/mathern/sigsev-…
tmathern Aug 26, 2026
ab110f7
fix: Rewrite some threaded tests to avoid multifork issues
tmathern Aug 26, 2026
fc630b8
fix: Docs
tmathern Aug 26, 2026
e657a23
fix: Rebaseline
tmathern Aug 26, 2026
63fc5a7
fix: Reorder locking
tmathern Aug 26, 2026
cbda080
fix: Handle fragments better
tmathern Aug 26, 2026
dfaaac1
fix: Handle fragments better 2
tmathern Aug 26, 2026
ea1dac5
fix: Docs
tmathern Aug 26, 2026
5ebe99a
fix: The test that checks lock ordering
tmathern Aug 26, 2026
bd2de49
fix: The test that checks lock ordering
tmathern Aug 26, 2026
39acabd
fix: Double free scan
tmathern Aug 26, 2026
95cc465
fix: Fix a crash
tmathern Aug 26, 2026
93832b2
fix: Additional crashes handling (#315)
tmathern Aug 27, 2026
268a1ac
fix: Restore perf
tmathern Aug 27, 2026
f8b9dec
fix: Update docs
tmathern Aug 27, 2026
4ac0a10
fix: Update docs 3
tmathern Aug 27, 2026
fce5327
fix: Update docs
tmathern Aug 27, 2026
205ef5f
fix: Additional hardening and docs (#317)
tmathern Aug 28, 2026
121d963
fix: Make free function configurable (#318)
tmathern Aug 28, 2026
4a671ac
Merge branch 'main' into mathern/sigsev-sigabort
tmathern Aug 28, 2026
baea981
fix: Put a sentinel in the native thread local error slot (#312)
tmathern Sep 3, 2026
5bc138e
Merge branch 'main' into mathern/sigsev-sigabort
tmathern Sep 16, 2026
78443e9
fix: Demo notes
tmathern Sep 18, 2026
290598f
Merge branch 'main' into mathern/sigsev-sigabort
tmathern Sep 22, 2026
84b89f1
fix: Threading bench (#329)
tmathern Sep 22, 2026
b8b9cb8
fix: Rewrite the docs (#333)
tmathern Sep 25, 2026
6bed909
Merge branch 'main' into mathern/sigsev-sigabort
tmathern Sep 25, 2026
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
52 changes: 52 additions & 0 deletions .github/workflows/threading-benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Python SDK threading checks

on:
pull_request:
types:
- opened
- reopened
- synchronize
- labeled

permissions:
contents: read

jobs:
threading-benchmark:
name: Python SDK threading checks
runs-on: ubuntu-24.04-arm
# Backstop: In case there is a hang.
timeout-minutes: 20
if: |
contains(github.event.pull_request.labels.*.name, 'check-threading-benchmark') &&
(
github.event.pull_request.author_association == 'COLLABORATOR' ||
github.event.pull_request.author_association == 'MEMBER' ||
github.event.pull_request.author_association == 'OWNER'
)
steps:
- uses: actions/checkout@v4

- name: Build perf image
run: make perf-image
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Make sure crashes would be reported.
- name: Check the harness can detect failures
run: make threading-bench-self-test
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Run thread-safety invariants
run: make threading-bench
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload failure logs
if: always()
uses: actions/upload-artifact@v4
with:
name: threading-invariant-logs
path: tests/perf/reports/*-threads.log
if-no-files-found: ignore
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,6 @@ src/c2pa/libs/
# Memory profiling reports
tests/perf/reports/*.html
tests/perf/reports/*.bin

# Threading failure logs
tests/perf/reports/*.log
22 changes: 22 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,25 @@ memory-use-bench:
clean-memory-perf-reports:
rm -f tests/perf/reports/*.html tests/perf/reports/*.bin
@echo "Cleared tests/perf/reports/"

# Thread-safety invariants (runs in Docker, same image as the memory benchmark)
# More details for usage are in tests/perf/README.md
THREAD_ROUNDS ?= 20

# Checks that the harness itself reports crashes, hangs and plain exceptions
# correctly. A harness that cannot see a failure is indistinguishable from a
# passing run, so this gates the real suite rather than documenting it.
.PHONY: threading-bench-self-test
threading-bench-self-test: perf-image
docker run --rm -v $(PWD):/workspace -e PYTHONPATH=/workspace/src -e GITHUB_TOKEN c2pa-memray-$(PERF_ENV) python -m tests.perf.run_thread_profile --self-test

# Runs the thread-safety invariant scenarios. Pre-requisite: Docker image built
# using `make perf-image` (or `perf-image-rebuild`).
.PHONY: threading-bench
threading-bench: threading-bench-self-test
docker run --rm -v $(PWD):/workspace $(GH_SUMMARY_MOUNT) -e PYTHONPATH=/workspace/src -e PERF_ENV=$(PERF_ENV) -e THREAD_ROUNDS=$(THREAD_ROUNDS) -e THREAD_HANG_TIMEOUT -e GITHUB_TOKEN -e GITHUB_STEP_SUMMARY c2pa-memray-$(PERF_ENV) python -m tests.perf.run_thread_profile $(SCENARIO_ARG) $(PERF_ARGS)

.PHONY: clean-threading-reports
clean-threading-reports:
rm -f tests/perf/reports/*-threads.log
@echo "Cleared tests/perf/reports/*-threads.log"
2 changes: 2 additions & 0 deletions docs/context-settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,8 @@ ctx = Context()
assert isinstance(ctx, ContextProvider) # True
```

A provider that does not derive from `ManagedResource` runs without in-flight teardown protection. `Reader` and `Builder` check `is_valid` before use, but nothing defers a teardown that arrives mid-construction, so closing such a provider on another thread while a `Reader` or `Builder` is being built from it can free the native context while that construction is still using it. The built-in `Context` carries that protection. Custom providers that share a context across threads should keep it alive for the duration of any construction that uses it.

## Migrating from load_settings

The `load_settings()` function is deprecated. Replace it with `Settings` and `Context` APIs:
Expand Down
684 changes: 269 additions & 415 deletions docs/native-resources-management.md

Large diffs are not rendered by default.

Loading
Loading