Patch for fixing various Segmentation faults due lack of Global Interpreter Locking

Bug #554299 reported by Jonas H on 2010-04-02
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
PyJavaScriptCore
Medium
Martin Soto

Bug Description

I herewith send you a patch that fixes various Segmentation faults that occur due the lack of proper Global Interpreter Locking (GIL).

In some cases if you accessed/called Javascript objects/functions from within multiple threads, Python crashed with segmentation faults because `PyThreadState_GET` returned a null-pointer. This is due the lack of proper GI locking.

The patch has to be applied to current bzr revision.

Jonas H (jonash) wrote :
description: updated
Jonas H (jonash) wrote :

Humm, I mixed revisions, reversed patch. Here comes the right one.

Martin Soto (soto255) wrote :

First of all, sorry for the late answer, I was out of town. I just applied a fix along the lines of this patch, but not the patch itself. As it turns out, several functions (not only those you fixed in the patch) were missing a "with gil" clause. This is now fixed in bzr. Many thanks for pointing this out!

The change to the __call__ method in _JSFunction, on the other hand, seems highly suspicious to me. This will always prevent JS code called from Python from running concurrently, which shouldn't generally be a problem, because JavaScriptCore is thread-safe. Notice, however, that your change may still have the side effect of preventing segfaults in *your* code, because of the higher degree of mutual exclusion it introduces. By the way, JavaScriptCore is thread-safe, but WebKit itself isn't, so you have to make sure that you're not calling into the same WebKit instance from several threads (see, for example http://lists.apple.com/archives/Webkitsdk-dev/2009/Jul/msg00023.html).

I would suggest that you test your code with my fixed version and let me know if the problems persist.

Changed in pyjavascriptcore:
status: New → Confirmed
importance: Undecided → Medium
assignee: nobody → Martin Soto (soto255)
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers