Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add ALTREP guard to prevent unsafe R calls from ALTREP methods#1797

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
Copilot wants to merge3 commits intomain
base:main
Choose a base branch
Loading
fromcopilot/fix-rapi-error-context-safety

Conversation

Copy link
Contributor

CopilotAI commentedDec 1, 2025
edited
Loading

rapi_error_with_context() jumps into R, which is unsafe from ALTREP method callbacks and can cause stack overflows.

Changes

  • AltrepGuard class (src/include/rapi.hpp): Thread-local RAII guard with depth counter to track ALTREP method execution context
  • rapi_error_with_context() modification (src/utils.cpp): When guard is active, throwsstd::runtime_error instead of calling into R. TheBEGIN_CPP11/END_CPP11 macros catch this and convert to R error safely.
  • Guard activation (src/reltoaltrep.cpp): AddedAltrepGuard guard; to all 11 ALTREP method callbacks

Example

// In ALTREP method callbackR_xlen_tRelToAltrep::VectorLength(SEXP x) {    BEGIN_CPP11    AltrepGuard guard;// Activates guard for this scopereturnAltrepVectorWrapper::Get(x)->rel->GetQueryResult()->RowCount();// If GetQueryResult() calls rapi_error_with_context(),// it now throws instead of calling REND_CPP11_EX(0)}

Error messages change from multi-line format toContext: Message but retain same information.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • cloud.r-project.org
    • Triggering command:/opt/R/4.5.2/lib/R/bin/exec/R /opt/R/4.5.2/lib/R/bin/exec/R -q -e options(repos~+~=~+~c(CRAN~+~=~+~'REDACTED'));~+~install.packages(c('DBI',~+~'testthat',~+~'cpp11',~+~'rlang'),~+~type='source') (dns block)
  • cran.r-project.org
    • Triggering command:/opt/R/4.5.2/lib/R/bin/exec/R /opt/R/4.5.2/lib/R/bin/exec/R -q -e install.packages(c('DBI',~+~'testthat',~+~'cpp11',~+~'rlang'),~+~repos='REDACTED') (dns block)
    • Triggering command:/usr/bin/curl curl -sI REDACTED (dns block)
  • p3m.dev
    • Triggering command:/opt/R/4.5.2/lib/R/bin/exec/R /opt/R/4.5.2/lib/R/bin/exec/R -q -e options(repos~+~=~+~c(CRAN~+~=~+~'REDACTED'));~+~install.packages(c('DBI',~+~'testthat',~+~'cpp11',~+~'rlang')) (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Callingrapi_error_with_context() is unsafe from ALTREP methods</issue_title>
<issue_description>rapi_error_with_context() jumps into R, this appears to be unsafe or unsupported for ALTREP methods. I have seen stack overflows occur from this.

Define a guard that is activated whenever an ALTREP method is entered. Query this guard inrapi_error_with_context() and fall back to throwing an exception instead of calling into R viarapi_error() .</issue_description>

Comments on the Issue (you are@copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn moreCopilot coding agent tips in the docs.

CopilotAIand others added2 commitsDecember 1, 2025 20:44
Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com>
Co-authored-by: krlmlr <1741643+krlmlr@users.noreply.github.com>
CopilotAI changed the title[WIP] Fix safety issue when calling rapi_error_with_context in ALTREP methodsAdd ALTREP guard to prevent unsafe R calls from ALTREP methodsDec 1, 2025
CopilotAI requested a review fromkrlmlrDecember 1, 2025 20:48
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@krlmlrkrlmlrAwaiting requested review from krlmlr

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Callingrapi_error_with_context() is unsafe from ALTREP methods

2 participants

@krlmlr

[8]ページ先頭

©2009-2025 Movatter.jp