Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix segfaults when large numbers of contexts.
Turns out that I had an error in my logic about how to reference count the python context object. I removed references to it from Python objects that are wrapped in the JavaScript VM. I'm more than 50% certain that this is correct as when the Python context dies, it'll destroy the JSContext* and along with it all references to Python objects that need refernces to the Context. [#21 state:resolved]
- Loading branch information
Showing
7 changed files
with
38 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,12 +20,17 @@ Runtime_new(PyTypeObject* type, PyObject* args, PyObject* kwargs) | |
if(self == NULL) goto error; | ||
|
||
self->rt = JS_NewRuntime(stacksize); | ||
if(self->rt == NULL) goto error; | ||
if(self->rt == NULL) | ||
{ | ||
PyErr_SetString(JSError, "Failed to allocate new JSRuntime."); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
davisp
Author
Owner
|
||
goto error; | ||
} | ||
|
||
goto success; | ||
|
||
error: | ||
Py_XDECREF(self); | ||
self = NULL; | ||
|
||
success: | ||
return (PyObject*) self; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Copyright 2009 Paul J. Davis <paul.joseph.davis@gmail.com> | ||
# | ||
# This file is part of the python-spidermonkey package released | ||
# under the MIT license. | ||
import t | ||
|
||
#def test_churn_runtimes(): | ||
# for i in range(1000): | ||
# rt = t.spidermonkey.Runtime() | ||
|
||
|
||
class Session(object): | ||
def __init__(self): | ||
self.key = None | ||
|
||
def set(self, key): | ||
self.key = key | ||
return self | ||
|
||
@t.rt() | ||
def test_churn_contexts(rt): | ||
for i in range(1000): | ||
cx = rt.new_context() | ||
cx.add_global('session', Session) | ||
data = cx.execute('new session().set("foo");') | ||
t.eq(data.key, "foo") | ||
|
I am starting to get this error with Ming.mim ... essentially I am creating a new JSRuntime for every test case, and with my test suite it starts to raise this exc. Any ideas of how I can work around this error?