Skip to content

Fix incorrect OtherContextException wrapper when the exception comes back to its creator context#13454

Closed
eregon wants to merge 3 commits into
oracle:masterfrom
eregon:bd/fix-migrateException
Closed

Fix incorrect OtherContextException wrapper when the exception comes back to its creator context#13454
eregon wants to merge 3 commits into
oracle:masterfrom
eregon:bd/fix-migrateException

Conversation

@eregon
Copy link
Copy Markdown
Contributor

@eregon eregon commented May 1, 2026

Summary

Fixes #13453

Testing

I wrote a test for this in truffle/src/com.oracle.truffle.api.instrumentation.test/src/com/oracle/truffle/api/instrumentation/test/TruffleContextTest.java with the help of Codex. It passes with the fix and fails without.

I also have tests in TruffleRuby for this: https://github.com/truffleruby/truffleruby/pull/4235/changes
I confirm this PR fixes #13453, as in those tests fail without and pass with this PR.

Documentation

No documentation updates are needed.

Contributor Checklist

  • I have read the contribution guide.
  • I have the right to contribute the submitted material under the project terms.
  • I have updated tests and documentation where appropriate.
  • If I used a coding assistant, I remain responsible for the entire contribution and have reviewed it accordingly.

Comment on lines 193 to 194
// TODO: Should the last arg be valueContext like in migrateValue?
throw new OtherContextException(receiverContext, other.delegate, other.delegateContext);
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.

migrateValue() does:

return new OtherContextGuestObject(this, otherValue.delegate, valueContext);

(in migrateValue(), this == receiverContext)

Which is correct?
I'm not sure what the receiverContext is for, wouldn't only tracking the delegateContext be enough?
Is it because the OtherContextGuestObject/OtherContextException objects need to belong to one context and not many? (if so, is that needed?)

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.

I (and Codex) have figured this out, it was another bug, this time in migrateValue().
Pushed a commit with a fix + test and verified the test passes with the fix and fails without.

@oubidar-Abderrahim
Copy link
Copy Markdown
Member

Thank you for the PR @eregon
@chumer could you please review, thanks

@eregon eregon force-pushed the bd/fix-migrateException branch 2 times, most recently from 8902d38 to 2f63ee5 Compare May 13, 2026 20:24
@eregon
Copy link
Copy Markdown
Contributor Author

eregon commented May 13, 2026

@chumer @tzezula I wrote a test now with the help of Codex (and reviewed it), and also addressed the comment above which turned out to be a second bug, so now this PR fixes 2 bugs and adds a test for each. Please review.

@eregon
Copy link
Copy Markdown
Contributor Author

eregon commented May 13, 2026

Ah during rebasing I noticed @iamstolis already fixed the second bug in 5b5c93a / #13522.
I'll drop my last commit then as that's already fixed & tested.

@eregon eregon force-pushed the bd/fix-migrateException branch from 2f63ee5 to bae99da Compare May 13, 2026 20:31
Copy link
Copy Markdown
Member

@tzezula tzezula left a comment

Choose a reason for hiding this comment

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

Looks good to me.
It unwraps the object originated in the targetContext rather than creating a decorator chain.

@chumer
Copy link
Copy Markdown
Member

chumer commented May 22, 2026

lgtm. inbounding the PR. sorry for the delay.

@chumer
Copy link
Copy Markdown
Member

chumer commented May 27, 2026

PR is merged here: #13599
(will reuse your branch next time, to track this properly, sorry)

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

Labels

OCA Verified All contributors have signed the Oracle Contributor Agreement. truffle

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Exception from inner context is incorrectly wrapped, causing AssertionError and infinite cause chains

4 participants