Skip to content

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

Open
eregon wants to merge 3 commits intooracle:masterfrom
eregon:bd/fix-migrateException
Open

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

Conversation

@eregon
Copy link
Copy Markdown
Contributor

@eregon eregon commented May 1, 2026

Summary

Fixes #13453

Testing

I tried to write a test for this in truffle/src/com.oracle.truffle.api.instrumentation.test/src/com/oracle/truffle/api/instrumentation/test/TruffleContextTest.java but didn't find a way to pass the outer exception in a lambda to the inner context and call it from there.
The existing tests look confusing to me, lines like result = InteropLibrary.getUncached().execute(result, outerObject); seem rather obscure.
I would appreciate if you can write the test or help me find out how to pass the exception between the different contexts.

I do 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?)

@oubidar-Abderrahim
Copy link
Copy Markdown
Member

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

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

2 participants