[pypy-commit] pypy fix-vmprof-stacklet-switch: add a test which is failing (i.e., segfaulting) on default, and that it seems to be fixed on this branch

antocuni pypy.commits at gmail.com
Wed Nov 15 10:07:24 EST 2017


Author: Antonio Cuni <anto.cuni at gmail.com>
Branch: fix-vmprof-stacklet-switch
Changeset: r93036:52a6650ba479
Date: 2017-11-15 15:49 +0100
http://bitbucket.org/pypy/pypy/changeset/52a6650ba479/

Log:	add a test which is failing (i.e., segfaulting) on default, and that
	it seems to be fixed on this branch

diff --git a/pypy/module/_continuation/test/test_translated.py b/pypy/module/_continuation/test/test_translated.py
--- a/pypy/module/_continuation/test/test_translated.py
+++ b/pypy/module/_continuation/test/test_translated.py
@@ -5,6 +5,7 @@
     py.test.skip("to run on top of a translated pypy-c")
 
 import sys, random
+from rpython.tool.udir import udir
 
 # ____________________________________________________________
 
@@ -92,6 +93,33 @@
         from pypy.conftest import option
         if not option.runappdirect:
             py.test.skip("meant only for -A run")
+        cls.w_vmprof_file = cls.space.wrap(str(udir.join('profile.vmprof')))
+
+    def test_vmprof(self):
+        """
+        The point of this test is to check that we do NOT segfault.  In
+        particular, we need to ensure that vmprof does not sample the stack in
+        the middle of a switch, else we read nonsense.
+        """
+        try:
+            import _vmprof
+        except ImportError:
+            py.test.skip("no _vmprof")
+        #
+        def switch_forever(c):
+            while True:
+                c.switch()
+        #
+        f = open(self.vmprof_file, 'w+b')
+        _vmprof.enable(f.fileno(), 1/250.0, False, False, False, False)
+        c = _continuation.continulet(switch_forever)
+        for i in range(10**7):
+            if i % 100000 == 0:
+                print i
+            c.switch()
+        _vmprof.disable()
+        f.close()
+
 
 def _setup():
     for _i in range(20):
@@ -124,7 +152,8 @@
     try:
         import thread
     except ImportError:
-        py.test.skip("no threads")
+        py.test.ski
+        p("no threads")
     ts = [ThreadTest(thread.allocate_lock()) for i in range(5)]
     for t in ts:
         thread.start_new_thread(t.run, ())


More information about the pypy-commit mailing list