[DEBUG — do not merge] localize Windows-only native crash - #62
Closed
jemus42 wants to merge 20 commits into
Closed
Conversation
…, split_decay_rate, delete_leaves ) and different behaviour of split_try
… split_structure.
…, threading. Fixed bug in split_structure="leaves" mode; changed behaviour of split_structure="res_trees" mode to fit description. Update documentation and examples for clarity.
…_try' of github.com:PlantedML/randomPlantedForest into new-max_candidates-split_decay_rate-delete_leaves-split_try
Two changes to turn the silent Windows crash into actionable output: - src/include/helper.hpp: harden utils::Matrix::operator[] — bounds-check every dimension (the first index was previously unchecked) and use >= for the flat-index guard (previously > allowed reading one past the end). Out-of-bounds access now throws with the offending dimension and index. - tests/testthat.R: TEMPORARY harness that runs each test file in its own R child process with BEGIN/END markers, so the crashing file is visible in testthat.Rout even when the child dies natively. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Crash localized to test-rpf-reproducibility.R, exit 0xC0000005 during rpf(nthreads = 2). Matrix bisects: thread count, ntrees, deterministic, purify, fit-vs-predict, repeat fits. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Matrix v1 result: ALL nthreads>=2 fits crash at fit1 (0xC0000005), even ntrees=1 (single worker thread, no concurrency); nthreads=1 passes. So: any create_tree_family on a non-main thread dies on Windows. v2: fprintf(stderr) stage markers in training.cpp thread lambda and create_tree_family (leaves path), gated behind RPF_DEBUG env var; matrix reduced to (1) instrumented single-worker fit, (2) serial fit + threaded purify mode 2, (3) serial fit + threaded purify mode 1. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Root cause of the Windows-only crash (0xC0000005) in threaded fit: the namespace-scope thread_local std::vector<std::vector<int>> tls_working_bin_id registers an emutls destructor when touched by a worker thread. On Windows (MinGW/Rtools, package DLL loaded via LoadLibrary), running that destructor at std::thread exit crashes the process. Proven via marker instrumentation: worker completed all work ([thr 0] exit printed), process died during thread teardown; threaded purify, which touches no non-trivial TLS, passes on Windows. Fix follows the existing tls_rng_ptr pattern: TLS holds only a POD pointer; the buffer is a stack-owned local in create_tree_family. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Collaborator
Author
|
Root cause found and fix verified: thread_local std::vector (tls_working_bin_id) registers an emutls destructor that crashes at std::thread exit on Windows (MinGW, DLL via LoadLibrary). Replacing it with a trivially-destructible TLS pointer to a stack-owned buffer makes windows-latest pass (run of bf83921). Fix will land on #61. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Temporary instrumentation to localize the Windows-only native crash seen on #61 (run 29271102587): hardened
utils::Matrix::operator[]bounds checks (unchecked first index, off-by-one flat guard) + per-file child-process test harness with markers that survive a native crash. Will be closed once the culprit is identified.🤖 Generated with Claude Code