Skip to content

Forward error_call value in Pool$release - #205

Merged
hadley merged 2 commits into
rstudio:mainfrom
sims1253:fix/ry-audit-round2
Sep 16, 2026
Merged

hadley merged 2 commits into
rstudio:mainfrom
sims1253:fix/ry-audit-round2

Conversation

@sims1253

Copy link
Copy Markdown
Contributor

Pool$release() forwarded its error context with:

pool_metadata(object, error_call = error_call())

The local error_call formal holds an environment, the result of caller_env(). R function lookup skips bindings that are not functions, so error_call() resolved to rlang::error_call(), which requires call and errored with argument "call" is missing, with no default.

pool_metadata() forces error_call only on its abort paths, so the bug is latent: releasing a valid pooled object works, but releasing an object that is not pooled or is no longer valid died with that error instead of the intended message. The value is now forwarded without the call parentheses.

Found during my most recent ry audit.

@CLAassistant

CLAassistant commented Sep 13, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@hadley hadley left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for spotting this!

Comment thread tests/testthat/test-pool.R Outdated
pool <- poolCreate(function() 1)
defer(poolClose(pool))

expect_error(pool$release(1), "not an pooled object")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please use expect_snapshot() here so we can see the call it uses?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Just a quick check: When I call it from the test, the caller is the test environment, which has no call to show. Do you want me to wrap it in a helper function so there is an actual call to see?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes please! (There's some trickiness sometimes with OO dispatch that I don't think affects R6, but is good to double check).

@hadley
hadley merged commit d390fbe into rstudio:main Sep 16, 2026
1 check failed
@hadley

hadley commented Sep 16, 2026

Copy link
Copy Markdown
Member

Thank you!

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.

3 participants