Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segfault/Access Violation when calling local function made with Reflect.makeVarArgs in another function #735

Open
NotHyper-474 opened this issue Dec 26, 2024 · 3 comments

Comments

@NotHyper-474
Copy link

NotHyper-474 commented Dec 26, 2024

Haxe 4.3.6
HashLink 1.14.0
Repro code: https://try.haxe.org/#F21Ca171
If I explicitly mark func as Dynamic it works without issues.
Other targets work as expected.

I also noticed that on Windows it'll throw an error instead.

source/Main.hx:7: Haxe is great!
Uncaught exception: Access violation
Called from $Main.testFunc(Main.hx:17)
Called from $Main.main(Main.hx:13)
Called from .init(?:1)
@NotHyper-474 NotHyper-474 changed the title Segfault when calling local function made with Reflect.makeVarArgs on another function Segfault when calling local function made with Reflect.makeVarArgs in another function Dec 26, 2024
@NotHyper-474 NotHyper-474 changed the title Segfault when calling local function made with Reflect.makeVarArgs in another function Segfault/Access Violation when calling local function made with Reflect.makeVarArgs in another function Dec 30, 2024
@yuxiaomao
Copy link
Collaborator

I confirm that I can repro with your example with latest hashlink.

I note the example here just in case:

class Main {
	static function main() {
		var func = function(args:Array<Dynamic>):Void {
			trace("Haxe is great!");
		};

		var f2 /*: Dynamic*/ = Reflect.makeVarArgs(func);
		f2([]); // Works as expected
		testFunc(f2);
	}

	static function testFunc(func:Dynamic) {
		func([]); // Segfaults if f2 is not type explicitly as Dynamic
	}
}

@NotHyper-474
Copy link
Author

Interestingly your example also only fails if f2([]); is present.

@yuxiaomao
Copy link
Collaborator

yuxiaomao commented Jan 9, 2025

It segfault for hl/c and hl/jit.
It also only fails if :Dynamic is present in testFunc(func:Dynamic). And will not fail if it's Dynamic->Void either.
Seems to be caused by f2's type, it's typed as Array<Dyn>->Void (caused by f2([])) and passed as Dyn, and hashlink somehow don't like it. I'll see if I can find some fix.

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

No branches or pull requests

2 participants