Skip to content

Commit 60e708c

Browse files
committed
issues.md: issue-007
Signed-off-by: Tzanko Matev <[email protected]>
1 parent 866cf81 commit 60e708c

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

issues.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,85 @@ when `Raw` is expected) and update tests to assert the exact kind.
123123
Done
124124

125125
Stricter tests now assert `str` values are encoded as `String` with the exact text payload, and runtime docs clarify canonical encoding. No runtime logic change was required since `encode_value` already produced `String` for Python `str`.
126+
127+
## ISSUE-006
128+
### Description
129+
Accidental check-in of Cargo cache/artifact files under `codetracer-python-recorder/.cargo/**` (e.g., `registry/CACHEDIR.TAG`, `.package-cache`). These are build/cache directories and should be excluded from version control.
130+
131+
### Definition of Done
132+
- Add ignore rules to exclude Cargo cache directories (e.g., `.cargo/**`, `target/**`) from version control.
133+
- Remove already-checked-in cache files from the repository.
134+
- Verify the working tree is clean after a clean build; no cache artifacts appear as changes.
135+
136+
### Status
137+
Done
138+
139+
## ISSUE-007
140+
### Description
141+
Immediately stop tracing when any monitoring callback raises an error.
142+
143+
Current behavior: `RuntimeTracer::on_py_start` intentionally fails fast when it
144+
cannot capture function arguments (e.g., when `sys._getframe` is unavailable or
145+
patched to raise). The callback error is propagated to Python via
146+
`callback_py_start` (it returns the `PyResult` from `on_py_start`). However, the
147+
tracer remains installed and active after the error. As a result, any further
148+
Python function start (even from exception-handling or printing the exception)
149+
triggers `on_py_start` again, re-raising the same error and interfering with the
150+
program’s own error handling.
151+
152+
This is observable in `codetracer-python-recorder/tests/test_fail_fast_on_py_start.py`:
153+
the test simulates `_getframe` failure, which correctly raises in `on_py_start`,
154+
but `print(e)` inside the test’s `except` block invokes codec machinery that
155+
emits additional `PY_START` events. Those callbacks raise again, causing the test
156+
to fail before reaching its assertions.
157+
158+
### Impact
159+
- Breaks user code paths that attempt to catch and handle exceptions while the
160+
tracer is active — routine operations like `print(e)` can cascade failures.
161+
- Hard to debug because the original error is masked by subsequent callback
162+
errors from unrelated modules (e.g., `codecs`).
163+
164+
### Proposed Solution
165+
Fail fast and disable tracing at the first callback error.
166+
167+
Implementation sketch:
168+
- In each callback wrapper (e.g., `callback_py_start`), if the underlying
169+
tracer method returns `Err`, immediately disable further monitoring before
170+
returning the error:
171+
- Set events to `NO_EVENTS` (via `set_events`) to prevent any more callbacks.
172+
- Unregister all previously registered callbacks for our tool id.
173+
- Optionally call `finish()` on the tracer to flush/close writers.
174+
- Option A (hard uninstall): call `uninstall_tracer(py)` to release tool id
175+
and clear the registry. This fully tears down the tracer. Note that the
176+
high-level `ACTIVE` flag in `lib.rs` is not updated by `uninstall_tracer`,
177+
so either:
178+
- expose an internal “deactivate_from_callback()” in `lib.rs` that clears
179+
`ACTIVE`, or
180+
- keep a soft-stop in `tracer.rs` by setting `NO_EVENTS` and unregistering
181+
callbacks without touching `ACTIVE`, allowing `stop_tracing()` to be a
182+
no-op later.
183+
- Ensure reentrancy safety: perform the disable sequence only once (e.g., with
184+
a guard flag) to avoid nested teardown during callback execution.
185+
186+
Behavioral details:
187+
- The original callback error must still be propagated to Python so the user
188+
sees the true failure cause, but subsequent code should not receive further
189+
monitoring callbacks.
190+
- If error occurs before activation gating triggers, the disable sequence should
191+
still run to avoid repeated failures from unrelated modules importing.
192+
193+
### Definition of Done
194+
- On any callback error (at minimum `on_py_start`, and future callbacks that may
195+
return `PyResult`), all further monitoring callbacks from this tool are
196+
disabled immediately within the same GIL context.
197+
- The initial error is propagated unchanged to Python.
198+
- The failing test `test_fail_fast_on_py_start.py` passes: after the first
199+
failure, `print(e)` does not trigger additional tracer errors.
200+
- Writers are flushed/closed or left in a consistent state (documented), and no
201+
additional events are recorded after disablement.
202+
- Unit/integration tests cover: error in `on_py_start`, repeated calls after
203+
disablement are no-ops, and explicit `stop_tracing()` is safe after a
204+
callback-induced shutdown.
205+
206+
### Status
207+
Not started

0 commit comments

Comments
 (0)