Skip to content

[cppia] Fix missing jit exception checks for method calls#1212

Merged
Simn merged 8 commits intoHaxeFoundation:masterfrom
tobil4sk:fix/missing-jit-exception-checks
Feb 24, 2026
Merged

[cppia] Fix missing jit exception checks for method calls#1212
Simn merged 8 commits intoHaxeFoundation:masterfrom
tobil4sk:fix/missing-jit-exception-checks

Conversation

@tobil4sk
Copy link
Member

Even with #1188, some checks for jit exceptions in interp code were still missing. This causes control flow bugs when local functions interact with other code, as they are currently not jit compiled.

In short, we have to make sure an exception hasn't been thrown after evaluating the object for a method call.

@tobil4sk tobil4sk changed the title [cppia] Fix missing jit exception checks [cppia] Fix missing jit exception checks for method calls Apr 10, 2025
@tobil4sk tobil4sk force-pushed the fix/missing-jit-exception-checks branch from 2643240 to c75a21a Compare April 10, 2025 21:09
@Simn
Copy link
Member

Simn commented Apr 11, 2025

@hughsando Please check!

@tobil4sk
Copy link
Member Author

@hughsando Please check!

It would be worth double checking if the full BCR_CHECKs are required in all cases, perhaps in some places it's enough just to check only ctx->exception.

CallFunExpr has the full check after getting this, and CallDynamicFunction has it after each argument, so I based my changes off those two. Perhaps there was a genuine reason why Call, CallHaxe and CallMemberVTable might not require the BCR check everywhere.

In interp mode, we need to stop immediately if a jit exception has been
thrown.
This covers the CallHaxe bug
The host must be compiled with HXCPP_CATCH_SEGV so that seg faults are
handled as hxcpp exceptions.
This test verifies that the full BCR check is needed in CallHaxe::run
after runObject, otherwise the return is ignored and arguments continue
to be evaluated
@tobil4sk
Copy link
Member Author

It would be worth double checking if the full BCR_CHECKs are required in all cases, perhaps in some places it's enough just to check only ctx->exception.

I have added tests that verify that the full BCR check is needed for Call, CallHaxe, and CallMemberVTable. I had to use @:analyzer(ignore) to construct some pretty crazy expressions with return in different places where the old code would continue evaluating the args or even call the function despite a return.

So I think this is good to merge.

This didn't fix the issue in HaxeFoundation/haxe#12646, so that must be something else.

@Simn
Copy link
Member

Simn commented Feb 24, 2026

Hmm, this run seems to have had a weird state:

Run haxe compile-cpp.hxml -D HXCPP_M64 -D no_http
Error:  src/unit/TestCoroutines.hx:152: characters 29-52

 152 |  public function iterator():haxe.coro.AsyncIterator<Int> {
     |                             ^^^^^^^^^^^^^^^^^^^^^^^
     | Type not found : haxe.coro.AsyncIterator

This must mean that tests and std are not in-sync. Unrelated to this PR but something to look into because that can lead to all sorts of strange errors.

@tobil4sk
Copy link
Member Author

Yeah, it looks like it just clones the latest haxe repository even if the haxe from build.haxe.org is slightly older. I guess we should read the commit hash from the version and use that, which is what the azure script used to do:

HAXE_HASH=`[[ "$HAXE_VERSION" =~ ^.+\+(.+) ]] && echo ${BASH_REMATCH[1]}`

@Simn Simn merged commit f6376e7 into HaxeFoundation:master Feb 24, 2026
264 of 266 checks passed
@tobil4sk tobil4sk deleted the fix/missing-jit-exception-checks branch February 24, 2026 08:39
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.

2 participants