Skip to content

GH-55605: [R] Don't abort when comparing R extension types off the R thread - #55621

Closed
csarushan1729 wants to merge 1 commit into
apache:mainfrom
csarushan1729:GH-55605
Closed

csarushan1729 wants to merge 1 commit into
apache:mainfrom
csarushan1729:GH-55605

Conversation

@csarushan1729

@csarushan1729 csarushan1729 commented Nov 15, 2026 •

Copy link
Copy Markdown

Rationale for this change

Arrow sometimes needs to check if two extension types are the same. If the name and settings already match, done. If not, it asks R to decide. But when a dataset is being scanned on a background thread, R can't be asked from there. The code threw an error, nobody was there to catch it, and the whole R session got killed.

You can hit this by reading a dataset where two files use the same extension type but with different settings, using collect() or Scanner$create(ds)$ToTable().

What changes are included in this PR?

Now, if R can't be asked, the check just says "not equal" and moves on. That's what R's own default check would say anyway, because the settings are different. So instead of a crash, the scan stops with the usual "can't cast between extension types" error you already get on a single thread.

A few things stay the same:

  • On the main R thread, nothing changes. R is called directly and this new path never runs.
  • Inside RunWithCapturedR(), R is still called, and if it errors, that error comes through like before.

One limitation: on a background thread, if someone wrote their own ExtensionEquals() in a subclass, it won't get a chance to run. Two types with different settings will just count as different. Earlier this case crashed, so it's still better than before.

Are these changes tested?

Yes. In test-extension.R I added a test that writes two files with the same extension type but different settings. It checks that both collect() and Scanner$create(ds)$ToTable() give an R error. Before the fix, this test killed R (exit status 134).

I ran the full test-extension.R and everything passed (52 tests, no failures). I also ran test-dataset.R and test-safe-call-into-r.R, and they behave the same with and without the change.

Are there any user-facing changes?

Yes. Reading a dataset like this now gives a normal R error, and your R session stays open.

This PR contains a "Critical Fix". It stops a crash that happens with normal, documented use.

Was AI used for this PR?

In accordance to the AI generation guidelines, please disclose below whether and how AI was used in this PR.

PR code and description written by:

  • Human
  • AI

Reviewed before submission by:

  • Human
  • AI
  • Not reviewed

@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #55605 has been automatically assigned in GitHub to PR creator.

@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #55605 has no components, please add labels for components.

@thisisnic

Copy link
Copy Markdown
Member

I'm not entirely convinced by the answers to the "Was AI used for this PR?" section here

@thisisnic thisisnic closed this Nov 15, 2026
@thisisnic thisisnic reopened this Nov 15, 2026
@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #55605 has no components, please add labels for components.

@csarushan1729

Copy link
Copy Markdown
Author

@thisisnic Thanks for flagging this, and sorry that I missed putting it correctly. Now, I’ve updated the description. Happy to make any changes.

@thisisnic

Copy link
Copy Markdown
Member

Mind updating the PR description to be in your own words instead of AI generated? That would help with the review. Thanks!

@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #55605 has no components, please add labels for components.

@csarushan1729

csarushan1729 commented Nov 16, 2026 •

Copy link
Copy Markdown
Author

sure, I’ve rewritten the description (in my own words) 👍

@thisisnic thisisnic closed this Nov 17, 2026
@csarushan1729

csarushan1729 commented Nov 17, 2026 via email •

Copy link
Copy Markdown
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants