leonhd / unladen-swallow

Automatically exported from code.google.com/p/unladen-swallow
Other
1 stars 1 forks source link

differing signal behaviour in test case #134

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I've been trying to pair this one down, but it's been proving rather 
problematic- given the following set of invocations

mkdir tmp
cd tmp
wget http://pkgcore.org/releases/{pkgcore/pkgcore-
0.5.9.tar.bz2,snakeoil/snakeoil-0.3.6.tar.bz2}
tar jxf pkgcore-0.5.9.tar.bz2
tar jxf snakeoil-0.3.6.tar.bz2
mv snakeoil-0.3.6/snakeoil pkgcore-0.5.9
cd pkgcore-0.5.9
${python-unladen-binary} setup.py test --pure-python

pkgcore.test.test_spawn.test_cleanup_pids will reproducibly differ in 
behaviour from all versions of python (2.4/2.5/2.6/2.7/3.1/3.2)... so 
definitely something u-s related ;)

Unfortunately using import pdb;pdb.set_trace() on it makes the behaviour 
disappear, but via print debugging I've traced it to the inner kill 
invocation w/in cleanup_pids- specifically,

if os.waitpid(pid, os.WNOHANG) == (0,0):
  os.kill(pid, signal.SIGTERM)
  os.waitpid(pid, 0)  # here.

Now it's expected that the waitpid will hang if the process isn't dead yet- 
what differs between u-s and mainline python is this code normally works 
fine.

Additional testing (swapping in a different process than sleep to kill) w/ 
a custom signal handler to print if it receives a signal results in no 
signal being received for the target process.

So either the signal isn't being sent (quick straceing makes me think it 
is), or u-s's default signal handlers/ignored signals is differing leading 
to the new process not receiving the signal.

That's my theory right now at least, but I could be wrong.

Original issue reported on code.google.com by ferringb on 5 Feb 2010 at 10:17

GoogleCodeExporter commented 8 years ago
To be clear in addition, 'fine' here is not the 60s timeout for sleep occuring- 
the 
process should be sigterm'd from within cleanup_pids and have waitpid be 
basically 
instantaneous.

Original comment by ferringb on 5 Feb 2010 at 10:18

GoogleCodeExporter commented 8 years ago
I can't reproduce this.  Here's the snipped final output for python2.6:

======================================================================
FAIL: test_regen (pkgcore.test.merge.test_triggers.TestInfoRegen)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/reid/unladen-swallow/tmp/pkgcore-0.5.9/snakeoil/test/__init__.py", line
188, in run
    self.forced_extra_frame(testMethod)
  File "/home/reid/unladen-swallow/tmp/pkgcore-0.5.9/snakeoil/test/__init__.py", line
153, in forced_extra_frame
    test()
  File
"/home/reid/unladen-swallow/tmp/pkgcore-0.5.9/build/lib.linux-x86_64-2.6/pkgcore
/test/merge/test_triggers.py",
line 378, in test_regen
    self.assertEqual(list(o.regen(path, self.dir)), [])
  File "/home/reid/unladen-swallow/tmp/pkgcore-0.5.9/snakeoil/test/__init__.py", line
136, in assertEqual
    msg or '%r != %r' % (obj1, obj2))
AssertionError: ['/tmp/tmpONqLVS/foo.info'] != []

======================================================================
FAIL: test_trigger (pkgcore.test.merge.test_triggers.TestInfoRegen)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/reid/unladen-swallow/tmp/pkgcore-0.5.9/snakeoil/test/__init__.py", line
188, in run
    self.forced_extra_frame(testMethod)
  File "/home/reid/unladen-swallow/tmp/pkgcore-0.5.9/snakeoil/test/__init__.py", line
153, in forced_extra_frame
    test()
  File
"/home/reid/unladen-swallow/tmp/pkgcore-0.5.9/build/lib.linux-x86_64-2.6/pkgcore
/test/merge/test_triggers.py",
line 427, in test_trigger
    self.assertFalse(self.run_trigger('post_merge', [self.dir]))
AssertionError

----------------------------------------------------------------------
Ran 888 tests in 3.738s

FAILED (failures=2)

And again for unladen trunk:

======================================================================
FAIL: test_regen (pkgcore.test.merge.test_triggers.TestInfoRegen)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/reid/unladen-swallow/tmp/pkgcore-0.5.9/snakeoil/test/__init__.py", line
188, in run
    self.forced_extra_frame(testMethod)
  File "/home/reid/unladen-swallow/tmp/pkgcore-0.5.9/snakeoil/test/__init__.py", line
153, in forced_extra_frame
    test()
  File
"/home/reid/unladen-swallow/tmp/pkgcore-0.5.9/build/lib.linux-x86_64-2.6/pkgcore
/test/merge/test_triggers.py",
line 378, in test_regen
    self.assertEqual(list(o.regen(path, self.dir)), [])
  File "/home/reid/unladen-swallow/tmp/pkgcore-0.5.9/snakeoil/test/__init__.py", line
136, in assertEqual
    msg or '%r != %r' % (obj1, obj2))
AssertionError: ['/tmp/tmp5EwLlV/foo.info'] != []

======================================================================
FAIL: test_trigger (pkgcore.test.merge.test_triggers.TestInfoRegen)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/reid/unladen-swallow/tmp/pkgcore-0.5.9/snakeoil/test/__init__.py", line
188, in run
    self.forced_extra_frame(testMethod)
  File "/home/reid/unladen-swallow/tmp/pkgcore-0.5.9/snakeoil/test/__init__.py", line
153, in forced_extra_frame
    test()
  File
"/home/reid/unladen-swallow/tmp/pkgcore-0.5.9/build/lib.linux-x86_64-2.6/pkgcore
/test/merge/test_triggers.py",
line 427, in test_trigger
    self.assertFalse(self.run_trigger('post_merge', [self.dir]))
AssertionError

======================================================================
FAIL: test_object_derivatives 
(pkgcore.test.test_slot_shadowing.Test_slot_shadowing)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/reid/unladen-swallow/tmp/pkgcore-0.5.9/snakeoil/test/__init__.py", line
188, in run
    self.forced_extra_frame(testMethod)
  File "/home/reid/unladen-swallow/tmp/pkgcore-0.5.9/snakeoil/test/__init__.py", line
153, in forced_extra_frame
    test()
  File
"/home/reid/unladen-swallow/tmp/pkgcore-0.5.9/snakeoil/test/test_slot_shadowing.
py",
line 28, in test_object_derivatives
    self.check_slotting(cls)
  File
"/home/reid/unladen-swallow/tmp/pkgcore-0.5.9/snakeoil/test/test_slot_shadowing.
py",
line 107, in check_slotting
    (kls, slots, raw_slottings[slots]))
AssertionError: cls <class 'pkgcore.test.package.test_base.Class'>; slots is
('__weakref__',), seemingly inherited from <class 'pkgcore.package.base.base'>-
should be __slots__ = ()

----------------------------------------------------------------------
Ran 888 tests in 4.392s

FAILED (failures=3)

So I don't know what the deal with the extra __weakref__ slot is, since it is 
present
on class base in base.py, but I can't find the relevant deadlock.

Original comment by reid.kle...@gmail.com on 20 Feb 2010 at 12:19

GoogleCodeExporter commented 8 years ago
Huh, close it- no longer can trigger this in current versions of u-s.  As for 
the 
__weakref__ complaint there, it looks for shadow slots- wasted memory and 
occasionally screwy behaviour.  Specifically it'll spot

class foo(object):
 __slots__ = ("dar",)

class bar(foo):
 __slots__ = ("dar",)

that bar.dar is redundantly overlapping foo.dar in terms of instance allocation.

Original comment by ferringb on 27 Feb 2010 at 2:56

GoogleCodeExporter commented 8 years ago
Closing, could not reproduce.  Thanks for the heads up, though.  Signal 
behavior is a
bit different because we're not running through the eval loop, but it should
hopefully work just as well.

Original comment by reid.kle...@gmail.com on 27 Feb 2010 at 5:14