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

task_detach crash with JIT #54

Open
badabingbadabooom opened this issue Apr 10, 2022 · 1 comment
Open

task_detach crash with JIT #54

badabingbadabooom opened this issue Apr 10, 2022 · 1 comment

Comments

@badabingbadabooom
Copy link

badabingbadabooom commented Apr 10, 2022

Using the task_detach function and later using any asynchronous function crashes the server if the script is JIT compiled.

Running this script in Windows and with jit_sleep enabled, the server crashes after "detached" gets printed on the console.

#include <PawnPlus>
#include <a_samp>
#include <jit>

public OnJITCompile()
{
	return 1;
}

myfunc(time)
{
	printf("myfunc(time = %i)", time);

	print("detaching...");
	task_detach();
	task_yield(1);
	print("detached");
	
	wait_ms(time);
	
	printf("%i milliseconds have passed", time);
	
	return 1;
}

main()
{
	new r = myfunc(1000);
	printf("myfunc returned %i", r); 
	return 0; 
}

With no JIT, it gives the expected output:

myfunc(time = 1000)
detaching...
detached
myfunc returned 1
Number of vehicle models: 0
1000 milliseconds have passed
@IS4Code
Copy link
Owner

IS4Code commented Apr 10, 2022

That can be expected. JIT converts the AMX code to native code, while task_detach expects the stack and frame pointers to point to memory using standard AMX layout. I may be able to turn the crash into an error, but support has to be provided by the JIT, as bad as it sounds.

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