Open GoogleCodeExporter opened 9 years ago
It seems that the JSEngine.collect() call is required to stop the segfault.
The exceptions were of course stopping this at the end of the call.
Original comment by ndudfi...@gmail.com
on 8 Feb 2013 at 6:06
Compare
def testDestructor(self):
JSEngine.collect()
return
vs
def testDestructor(self):
return
Original comment by ndudfi...@gmail.com
on 8 Feb 2013 at 6:08
In general the test suite seems to be sensitive to test execution ordering
Original comment by ndudfi...@gmail.com
on 8 Feb 2013 at 6:48
http://code.google.com/p/pyv8/issues/detail?id=108
Original comment by ndudfi...@gmail.com
on 8 Feb 2013 at 6:51
Interestingly, you can see that running the single failing test case works fine
in isolation.
➜ pyv8 python3.3 build/lib.linux-x86_64-3.3/PyV8.py -v
TestWrapper.testDestructor
2013-02-08 16:12:19,811 INFO testing PyV8 module 1.0 with V8 v3.16.13
testDestructor (__main__.TestWrapper) ... ok
----------------------------------------------------------------------
Ran 1 test in 0.017s
OK
Original comment by ndudfi...@gmail.com
on 8 Feb 2013 at 9:14
Try the following test suites, in precise order (pass as sys.argv)
TestContext TestDebug TestEngine TestWrapper
TestDebug TestEngine TestMultithread TestWrapper
Those combinations/sequences cause segfaults ( along with many others, but
these have the property of being short and `sorted` )
Original comment by ndudfi...@gmail.com
on 8 Feb 2013 at 9:18
Original comment by flier...@gmail.com
on 8 Feb 2013 at 11:56
@flier
Dunno, if this is of any interest to you:
def testDestructor(self):
"""
This illustrates some weird behaviour with dangling references that
haven't been explicitly `del` eted
Seemingly other test methods aren't cleaning up and causing similar
issues.
"""
with JSContext() as reference_that_cause_this_test_to_fail:
"The __exit__ deletes self but in this frame reference"
"dangles thus Dispose aint called"
class Hello(object):
deleted = False
def say(self): pass
def __del__(self):
Hello.deleted = True
# We won't put this in a test() closure with automatic
# deletion, cause we want to be explicit about what references
# we are deleting
with JSContext() as ctxt:
fn = ctxt.eval("b = function (obj) { obj.say(); }; b")
obj = Hello()
self.assertEqual(2, sys.getrefcount(obj))
fn(obj)
self.assertEqual(4, sys.getrefcount(obj))
self.assertFalse(Hello.deleted)
# You MUST delete ALL these references
del fn
del obj
del ctxt
# Try and collect
JSEngine.collect(force=True)
# What's interesting is at this point it's STILL not deleted
# (assuming reference_that_cause_this_test_to_fail is uncommented)
self.assertFalse(Hello.deleted)
# Now by deleting THIS reference, then running the collector
# finally our __del__ method gets ran
del reference_that_cause_this_test_to_fail
JSEngine.collect(force=True)
# Yes, it has definitely been ran
self.assertTrue(Hello.deleted)
Original comment by ndudfi...@gmail.com
on 8 Feb 2013 at 12:17
Thanks for your hints, it seems that two context have week relation, I will
analyze it more depth later.
Original comment by flier...@gmail.com
on 8 Feb 2013 at 2:23
Do you have a donation link? :)
Original comment by ndudfi...@gmail.com
on 8 Feb 2013 at 2:25
Thanks for your kindness, I'm working just for fun, or maybe later :)
Original comment by flier...@gmail.com
on 8 Feb 2013 at 2:28
Probably a dream, but would be nice if the many thousands of ZenCoding/Emmet
users wanting PyV8 for sublime 3 would contribute to your project :)
Original comment by ndudfi...@gmail.com
on 8 Feb 2013 at 2:44
@Flier
Just a follow up. We aren't currently using the SUPPORT_TRACE_LIFECYCLE stuff
so undefined it and now we are seeing some stability!
//
// Trace the object lifecycle
//
// #define SUPPORT_TRACE_LIFECYCLE 1
Original comment by ndudfi...@gmail.com
on 9 Feb 2013 at 9:52
Is this trace life cycle code needed ?
If I'm understanding correctly it's mostly for development/troubleshooting
diagnostics?
Original comment by ndudfi...@gmail.com
on 9 Feb 2013 at 10:05
In fact, the object tracer will improve the performance and reduce the memory
footprint, because the same JS object will use same Python wrapper object.
Original comment by flier...@gmail.com
on 9 Feb 2013 at 10:13
Thanks for the clarification. Yes, I just before saw the now failing test for
object caching :)
Just undefining the trace macro seems to avoid the segfaults, which allows
development to continue. Before, PyV8 was crashing the plugin_host process for
ST3
I'm just a script kiddy with enough C knowledge to be dangerous, so I can only
hope for youto remedy the sefaults in tracing code :)
Original comment by ndudfi...@gmail.com
on 9 Feb 2013 at 10:18
Thanks for your patient, I will check it later, because today is the Chinese
new year, so I must pay more attention to my family :P
Original comment by flier...@gmail.com
on 9 Feb 2013 at 11:29
Enjoy your holiday :)
Original comment by ndudfi...@gmail.com
on 9 Feb 2013 at 11:30
Any update on this?
Original comment by ndudfi...@gmail.com
on 16 Jun 2013 at 6:55
Original issue reported on code.google.com by
ndudfi...@gmail.com
on 8 Feb 2013 at 5:57