[issue20866] segfailt with os.popen and SIGPIPE

STINNER Victor report at bugs.python.org
Sat May 3 15:13:59 CEST 2014


STINNER Victor added the comment:

I can reproduce the crash. It occurs at the line "fd.write(data)". It looks like the crash occurs in the C function fwrite() which doesn't handle EPIPE / SIGPIPE correctly.

Top of the gdb traceback:

#0  0x00000033d0a8968b in __mempcpy_sse2 () from /lib64/libc.so.6
#1  0x00000033d0a79339 in __GI__IO_default_xsputn () from /lib64/libc.so.6
#2  0x00000033d0a77362 in __GI__IO_file_xsputn () from /lib64/libc.so.6
#3  0x00000033d0a6cfad in fwrite () from /lib64/libc.so.6
#4  0x0000000000435cc4 in file_write (f=0x7f46d74a2dc0, 
    args=('0123456789\n0123456789\n0123456789\n...(truncated))
    at Objects/fileobject.c:1852

Last syscalls (strace output):

...
pipe2([3, 4], O_CLOEXEC)                = 0
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f5ce26aca10) = 4711
close(3)                                = 0
fcntl(4, F_SETFD, 0)                    = 0
fstat(4, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
fstat(4, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f5ce26ca000
write(4, "0123456789\n0123456789\n0123456789"..., 1097728) = 98304
--- SIGPIPE {si_signo=SIGPIPE, si_code=SI_USER, si_pid=4710, si_uid=1000} ---
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=4711, si_status=0, si_utime=0, si_stime=0} ---
write(4, "89\n0123456789\n0123456789\n0123456"..., 999424) = -1 EPIPE (Broken pipe)
--- SIGPIPE {si_signo=SIGPIPE, si_code=SI_USER, si_pid=4710, si_uid=1000} ---
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x7f5cdbe87000} ---
+++ killed by SIGSEGV (core dumped) +++

----------
nosy: +haypo, neologix

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20866>
_______________________________________


More information about the Python-bugs-list mailing list