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

InterruptScriptThread implementation #6

Open
manison opened this issue Jan 15, 2017 · 4 comments
Open

InterruptScriptThread implementation #6

manison opened this issue Jan 15, 2017 · 4 comments

Comments

@manison
Copy link

manison commented Jan 15, 2017

I believe the implementation of InterruptScriptThread is not correct. In our application when the method is called it causes a deadlock. It's because the script engine hijacks our thread by setting its context (lethal SuspendThread/SetThreadContext/ResumeThread combination). This prevents our thread to clean-up safely. I think the script interruption is supposed to work in a cooperative way, as hinted in this FAQ:

InterruptScriptThread only instructs the script engine to stop executing code at the next opportunity. The call sets a flag that the script engine only checks when executing code.

and

IActiveScript::InterruptScriptThread will return E_INVALIDARG if an interrupt is already pending in the script thread (ie. waiting for the next statement to be executed)…

I think you should instruct the Ruby VM somehow to abort the execution at the next opportunity. If this is not possible (e.g. there is no API for it) then it would IMHO be better to indicate that the request is not supported (E_NOTIMPL) than fiddling with context of a thread you don't own.

@arton
Copy link
Owner

arton commented Jan 16, 2017

Right.
Thanks a lot.

@tukanos
Copy link

tukanos commented Jun 30, 2017

@arton: Did you, by any chance, have time to look at this issue? I'm trying to use your implementation and it failes on the threads, it kills the script.

@arton
Copy link
Owner

arton commented Jul 1, 2017

Hi tukanos,
I'd like to fix this issue. However, in this quarter, yes, I have no time to tackle it.
I wonder if you could wait until I can do it or PR the code to me.

@tukanos
Copy link

tukanos commented Jul 3, 2017

@arton : I can try to PR, but it will take some time to get to know your code :).

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

3 participants