Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segfault on time.sleep #67174

Closed
thedrow mannequin opened this issue Dec 2, 2014 · 4 comments
Closed

Segfault on time.sleep #67174

thedrow mannequin opened this issue Dec 2, 2014 · 4 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@thedrow
Copy link
Mannequin

thedrow mannequin commented Dec 2, 2014

BPO 22985
Nosy @vstinner, @thedrow

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2014-12-05.21:44:09.132>
created_at = <Date 2014-12-02.23:16:34.524>
labels = ['interpreter-core', 'invalid', 'type-crash']
title = 'Segfault on time.sleep'
updated_at = <Date 2014-12-06.16:55:52.007>
user = 'https://github.com/thedrow'

bugs.python.org fields:

activity = <Date 2014-12-06.16:55:52.007>
actor = 'Omer.Katz'
assignee = 'none'
closed = True
closed_date = <Date 2014-12-05.21:44:09.132>
closer = 'vstinner'
components = ['Interpreter Core']
creation = <Date 2014-12-02.23:16:34.524>
creator = 'Omer.Katz'
dependencies = []
files = []
hgrepos = []
issue_num = 22985
keywords = []
message_count = 4.0
messages = ['232059', '232214', '232241', '232247']
nosy_count = 2.0
nosy_names = ['vstinner', 'Omer.Katz']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = None
status = 'closed'
superseder = None
type = 'crash'
url = 'https://bugs.python.org/issue22985'
versions = ['Python 2.7', 'Python 3.4']

@thedrow
Copy link
Mannequin Author

thedrow mannequin commented Dec 2, 2014

I have found what appears to be a segfualt in time.sleep but I'm not sure.
I have verified that the segfualt occurs both on Python 2.7.8 and 3.4.2.

The following program that reproduces the segfault uses my fork of billiard, a replacement for the multiprocessing module that is used by celery.

In order to install: pip install git+https://github.com/thedrow/billiard@topic/dill-with-threads

The program:
from billiard.pool import ThreadPool

p1 = ThreadPool()

class Foo(object):
    def a(self):
        print("a")
        return 1

    def do(self):
        return p1.apply_async(self.a)


foo = Foo()
r = foo.do()

print(r.get())
p1.close()
p1.join()

The output from gdb:
gdb -ex r -q --args python mt_example.py
Reading symbols from python...done.
Starting program: /home/omer/.virtualenvs/billiard/bin/python mt_example.py
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff31db700 (LWP 2897)]
[New Thread 0x7ffff29da700 (LWP 2898)]
[New Thread 0x7ffff21d9700 (LWP 2899)]
[New Thread 0x7ffff19d8700 (LWP 2900)]
[New Thread 0x7ffff11d7700 (LWP 2901)]
[New Thread 0x7ffff09d6700 (LWP 2902)]
[New Thread 0x7fffdbfff700 (LWP 2903)]

Program received signal SIGTERM, Terminated.
[Switching to Thread 0x7ffff21d9700 (LWP 2899)]
0x00007ffff71dc1c3 in select () at ../sysdeps/unix/syscall-template.S:81
81 ../sysdeps/unix/syscall-template.S: No such file or directory.
(gdb) bt
#0 0x00007ffff71dc1c3 in select () at ../sysdeps/unix/syscall-template.S:81
#1 0x00007ffff5fd5d5d in floatsleep (secs=<optimized out>) at Modules/timemodule.c:948
#2 time_sleep (self=<optimized out>, args=<optimized out>) at Modules/timemodule.c:206
#3 0x00000000004b658c in call_function (oparg=<optimized out>, pp_stack=0x7ffff21d8540) at Python/ceval.c:4033
#4 PyEval_EvalFrameEx (f=f@entry=0x7ffff463eda8, throwflag=throwflag@entry=0) at Python/ceval.c:2679
#5 0x00000000004b6f6b in PyEval_EvalCodeEx (co=<optimized out>, globals=<optimized out>, locals=locals@entry=0x0, args=<optimized out>,
argcount=argcount@entry=4, kws=<optimized out>, kwcount=0, defs=0x7ffff40bab68, defcount=1, closure=0x0) at Python/ceval.c:3265
#6 0x00000000004b5b28 in fast_function (nk=<optimized out>, na=4, n=<optimized out>, pp_stack=0x7ffff21d8730, func=0x7ffff31e2938)
at Python/ceval.c:4129
#7 call_function (oparg=<optimized out>, pp_stack=0x7ffff21d8730) at Python/ceval.c:4054
#8 PyEval_EvalFrameEx (f=f@entry=0x7fffe8000b50, throwflag=throwflag@entry=0) at Python/ceval.c:2679
#9 0x00000000004b6f6b in PyEval_EvalCodeEx (co=<optimized out>, globals=<optimized out>, locals=locals@entry=0x0, args=<optimized out>,
argcount=argcount@entry=1, kws=<optimized out>, kwcount=0, defs=0x0, defcount=0, closure=0x0) at Python/ceval.c:3265
#10 0x00000000004b5b28 in fast_function (nk=<optimized out>, na=1, n=<optimized out>, pp_stack=0x7ffff21d8920, func=0x7ffff31e28c0)
at Python/ceval.c:4129
#11 call_function (oparg=<optimized out>, pp_stack=0x7ffff21d8920) at Python/ceval.c:4054
#12 PyEval_EvalFrameEx (f=f@entry=0x7fffe8000910, throwflag=throwflag@entry=0) at Python/ceval.c:2679
#13 0x00000000004b5bc7 in fast_function (nk=<optimized out>, na=1, n=<optimized out>, pp_stack=0x7ffff21d8a70, func=0x7ffff7e55230)
---Type <return> to continue, or q <return> to quit---
at Python/ceval.c:4119
#14 call_function (oparg=<optimized out>, pp_stack=0x7ffff21d8a70) at Python/ceval.c:4054
#15 PyEval_EvalFrameEx (f=f@entry=0x7ffff31f1210, throwflag=throwflag@entry=0) at Python/ceval.c:2679
#16 0x00000000004b6f6b in PyEval_EvalCodeEx (co=<optimized out>, globals=<optimized out>, locals=locals@entry=0x0,
args=args@entry=0x7ffff31dca68, argcount=<optimized out>, kws=kws@entry=0x0, kwcount=kwcount@entry=0, defs=defs@entry=0x0,
defcount=defcount@entry=0, closure=0x0) at Python/ceval.c:3265
#17 0x0000000000529e70 in function_call (func=0x7ffff7e55140, arg=0x7ffff31dca50, kw=0x0) at Objects/funcobject.c:526
#18 0x0000000000422f5a in PyObject_Call (func=func@entry=0x7ffff7e55140, arg=arg@entry=0x7ffff31dca50, kw=kw@entry=0x0)
at Objects/abstract.c:2529
#19 0x000000000042747d in instancemethod_call (func=0x7ffff7e55140, arg=0x7ffff31dca50, kw=0x0) at Objects/classobject.c:2602
#20 0x0000000000422f5a in PyObject_Call (func=func@entry=0x7ffff4636d70, arg=arg@entry=0x7ffff7f93050, kw=<optimized out>)
at Objects/abstract.c:2529
#21 0x00000000004b07f7 in PyEval_CallObjectWithKeywords (func=0x7ffff4636d70, arg=0x7ffff7f93050, kw=<optimized out>) at Python/ceval.c:3902
#22 0x00000000004fae92 in t_bootstrap (boot_raw=0x8899c0) at ./Modules/threadmodule.c:614
#23 0x00007ffff7bc40a5 in start_thread (arg=0x7ffff21d9700) at pthread_create.c:309
#24 0x00007ffff71e484d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

@thedrow thedrow mannequin added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump labels Dec 2, 2014
@vstinner
Copy link
Member

vstinner commented Dec 5, 2014

Program received signal SIGTERM, Terminated.

SIGTERM is not a segmentation fault. SIGSEGV is for segmentation faults.

@thedrow
Copy link
Mannequin Author

thedrow mannequin commented Dec 6, 2014

So why exactly the program terminates on a system call?

2014-12-05 23:44 GMT+02:00 STINNER Victor <report@bugs.python.org>:

STINNER Victor added the comment:

> Program received signal SIGTERM, Terminated.

SIGTERM is not a segmentation fault. SIGSEGV is for segmentation faults.

----------
nosy: +haypo
resolution: -> not a bug
status: open -> closed


Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue22985\>


@thedrow
Copy link
Mannequin Author

thedrow mannequin commented Dec 6, 2014

Capturing the signal provides the following traceback:
File "mt_example.py", line 10, in <module>
p1 = ThreadPool()
File "/home/omer/.virtualenvs/billiard/lib/python2.7/site-packages/billiard/pool.py", line 1016, in __init__
self._result_handler.start()
File "/home/omer/.virtualenvs/billiard/lib/python2.7/site-packages/billiard/pool.py", line 504, in start
super(PoolThread, self).start(*args, **kwargs)
File "/home/omer/.virtualenvs/billiard/lib/python2.7/site-packages/billiard/py2/dummy/init.py", line 69, in start
threading.Thread.start(self)
File "/home/omer/.pyenv/versions/2.7.8/lib/python2.7/threading.py", line 750, in start
self.__started.wait()
File "/home/omer/.pyenv/versions/2.7.8/lib/python2.7/threading.py", line 620, in wait
self.__cond.wait(timeout)
File "/home/omer/.pyenv/versions/2.7.8/lib/python2.7/threading.py", line 339, in wait
waiter.acquire()
File "mt_example.py", line 6, in handler
print(''.join(traceback.format_stack(frame)))

File "mt_example.py", line 10, in <module>
p1 = ThreadPool()
File "/home/omer/.virtualenvs/billiard/lib/python2.7/site-packages/billiard/pool.py", line 1016, in __init__
self._result_handler.start()
File "/home/omer/.virtualenvs/billiard/lib/python2.7/site-packages/billiard/pool.py", line 504, in start
super(PoolThread, self).start(*args, **kwargs)
File "/home/omer/.virtualenvs/billiard/lib/python2.7/site-packages/billiard/py2/dummy/init.py", line 69, in start
threading.Thread.start(self)
File "/home/omer/.pyenv/versions/2.7.8/lib/python2.7/threading.py", line 750, in start
self.__started.wait()
File "/home/omer/.pyenv/versions/2.7.8/lib/python2.7/threading.py", line 620, in wait
self.__cond.wait(timeout)
File "/home/omer/.pyenv/versions/2.7.8/lib/python2.7/threading.py", line 339, in wait
waiter.acquire()

The following code reproduces that traceback every time:
from billiard.pool import ThreadPool
import signal

def handler(signum, frame):
        import traceback
        print(''.join(traceback.format_stack(frame)))

signal.signal(signal.SIGTERM, handler)

p1 = ThreadPool()

class Foo(object):
    def a(self):
        print("a")
        return 1

    def do(self):
        return p1.apply_async(self.a)


foo = Foo()
r = foo.do()

print(r.get())
p1.close()
p1.join()

I'm convinced that there is a bug somewhere and it seems that Python is the source of the bug.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump
Projects
None yet
Development

No branches or pull requests

1 participant