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

[eval] If one thread is blocked other treads stop too #8525

Closed
RealyUniqueName opened this issue Jul 8, 2019 · 5 comments
Closed

[eval] If one thread is blocked other treads stop too #8525

RealyUniqueName opened this issue Jul 8, 2019 · 5 comments
Assignees
Labels
platform-eval Everything related to the Haxe 4 eval macro interpreter unresolved Issue was unresolved

Comments

@RealyUniqueName
Copy link
Member

class Main {
	public static function main() {
		var p = new sys.io.Process('haxe', ['-cmd', 'sleep 10']);
		sys.thread.Thread.create(() -> {
			Sys.println('hello');
			Sys.sleep(0.1);
			Sys.println('world'); // this is never printed
		});
		Sys.sleep(0.1);
		p.stdout.readByte();
	}
}
$ haxe -cp src --run Main
hello
<... hangs for 10 seconds ...>
/usr/share/haxe/std/eval/_std/sys/io/Process.hx:93: characters 4-9 : Uncaught exception Eof
/usr/share/haxe/std/eval/_std/sys/io/Process.hx:80: characters 7-27 : Called from here
src/Main.hx:18: characters 3-22 : Called from here
@RealyUniqueName RealyUniqueName added the platform-eval Everything related to the Haxe 4 eval macro interpreter label Jul 8, 2019
@RealyUniqueName RealyUniqueName added this to the Bugs milestone Jul 8, 2019
@Simn
Copy link
Member

Simn commented Jul 9, 2019

I don't think there's anything I can do here while Haxe is written in OCaml.

@ncannasse
Copy link
Member

That's strange, because performing I/O should release the global interpreter lock, allowing the other thread to execute.

@Simn
Copy link
Member

Simn commented Jul 30, 2019

The only thing we could do here is place some strategic Thread.yield() calls. In this particular case, the problem is that we're still using your Thread implementation from 1789, so OCaml has no idea what exactly we're doing.

My concern is that this would require yielding in a lot of places. I'm inclined to not touch this at all until we have a proper sys API in 4.1.

@Simn
Copy link
Member

Simn commented Jul 30, 2019

Actually, yielding isn't going to help here either because the Sys.sleep also yields, so depending on who yields first we just end up with the same situation.

@Simn Simn added the unresolved Issue was unresolved label Jun 5, 2020
@Simn
Copy link
Member

Simn commented Jun 5, 2020

I'm closing this because I still don't think there's anything I can do here.

@Simn Simn closed this as completed Jun 5, 2020
@RealyUniqueName RealyUniqueName changed the title [eva] If one thread is blocked other treads stop too [eval] If one thread is blocked other treads stop too Aug 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform-eval Everything related to the Haxe 4 eval macro interpreter unresolved Issue was unresolved
Projects
None yet
Development

No branches or pull requests

3 participants