Skip to content

Conversation

@PetterS
Copy link
Owner

@PetterS PetterS commented Aug 10, 2019

OK, this one was a bit tricky.

It started out with an issue happening rarely. Finally I was able to reliably reproduce it get a track trace in GDB which showed a segfault in strstr. That led to the fix in module.c.

The fix in module.c only turns a segfault into a Python exception, though. The issue is reliably reproduced by the added unit tests. Different threads accessing a QuickJS runtime is a problem, even if this happens at different times (this wrapper had locks for this reason). I interpreted the QuickJS documentation differently.

The fix is to force all JS execution to happen on a designated thread, either a single one globally or one per function.

order to save system resources if a large number of functions are created.
"""
if own_executor:
self._threadpool = concurrent.futures.ThreadPoolExecutor(max_workers=1)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only replaces the threadpool of this instance, right?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's right.

Copy link
Collaborator

@linussvarm linussvarm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@linussvarm linussvarm assigned PetterS and unassigned linussvarm Aug 11, 2019
@PetterS PetterS merged commit 91745fa into master Aug 11, 2019
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.

3 participants