Using a term or value after close(session) raises the raw C error R_ExternalPtrAddr instead of a closed-session diagnostic

Open
#355 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
r, rust
Domain
backend

Research direction

Start with close.rssn_session(), .rssn_default$get(), and the explicit-session paths named in the report: .rssn_cell(), term(), and format(). Trace how a closed session reaches .Call and identify the existing test entry points for these operations. Done means all five reported calls on a closed explicit session produce a clear closed-session diagnostic instead of the raw R_ExternalPtrAddr error.

Written by the indexing model from the issue text.

Description

area/api-bindings good first issue help wanted kind/contract severity/4-minor

After close(session), every operation on a term or value belonging to that session raises the raw R C-API error R_ExternalPtrAddr: argument of type NILSXP is not an external pointer instead of a diagnostic saying the session is closed.

library(rssn)
s <- rssn_session()
x <- sym("x", s); t <- x^2 + 1; v <- value_new(c(1, 2, 3), s)
close(s)
format(t)        # Error: R_ExternalPtrAddr: argument of type NILSXP is not an external pointer
compute(t)       # same
value_float(v)   # same
value_kind(v)    # same
value_count(s)   # same

All five calls fail with the identical internal message. A user sees a message about R_ExternalPtrAddr and NILSXP, which names neither the session nor the mistake.

close.rssn_session() sets con$ptr <- NULL, and every accessor then passes that NULL straight to .Call(C_rssn_..., session$ptr, ...). The package already has the right pattern for the default session: .rssn_default$get() recreates a session when value$ptr is NULL, which is why closing default_session() and continuing to use sym()/compute() works. An explicit session has no such guard, and .rssn_cell()/term()/format() do not check is.null(session$ptr) before the .Call.

This is related to but distinct from #245 (an answer's text survives close() while the renderers raise) and #221 (the Julia binding returns "" after close): here all R operations on a closed explicit session fail, and the failure is an internal C error rather than a documented one.

rssn 0.3.0, R 4.6.2 binding, Windows x86_64.

Dominant language
Rust
Stars
36
Forks
3
Avg merge
14h 51m
Merged PRs (30d)
29

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Apich-Organization/rssn

All issues in Apich-Organization/rssn

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.