Skip to content

fix(r): .onAttach/.onLoad crash on NULL kit.nThread - #70

Merged
davidbudzynski merged 3 commits into
fastverse:masterfrom
davidbudzynski:fix/56-nthread-null-crash
Sep 20, 2026
Merged

davidbudzynski merged 3 commits into
fastverse:masterfrom
davidbudzynski:fix/56-nthread-null-crash

Conversation

@davidbudzynski

Copy link
Copy Markdown
Collaborator

Closes #56.

Reattach with options(kit.nThread=NULL) failed: .onAttach did if (nth > 1L) on NULL (logical(0) -> 'argument is of length zero'); NA failed with 'missing value where TRUE/FALSE needed'; length>1 failed similarly.

  • R/call.R .onAttach: nth = getOption("kit.nThread", 1L) + if (is.null(nth) || length(nth) != 1L || is.na(nth)) nth = 1L; startup message only when interactive(). Keeps CompEnabledR naming.
  • .onLoad: reset default via is.null(getOption("kit.nThread")) instead of names() check.
  • test-nthread-opt.R (10 tests): .onLoad restore/preserve, .onAttach with NULL/NA/0/"2"/c(1L,2L), iif/vswitch with NULL default. Runs with OpenMP disabled (direct calls, no detach).
  • NEWS.md: bug-fix entry.

Verification: all 5 bad values attach clean, .onLoad restores 1L, Rscript startup silent, full tinytest suite green (1409 results).

Sanitize nth (NULL/length/NA -> 1L), reset default via is.null(getOption()), and only startup-message when interactive. Keeps CompEnabledR naming.
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.27%. Comparing base (99413b6) to head (4953cae).
⚠️ Report is 63 commits behind head on master.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #70      +/-   ##
==========================================
+ Coverage   98.01%   98.27%   +0.26%     
==========================================
  Files          13       13              
  Lines        5083     5100      +17     
==========================================
+ Hits         4982     5012      +30     
+ Misses        101       88      -13     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@davidbudzynski
davidbudzynski merged commit f1247b4 into fastverse:master Sep 20, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(r): .onAttach/.onLoad crash on NULL kit.nThread

2 participants