classification
Title: help(numpy) causes segfault on exit
Type: crash Stage: resolved
Components: Documentation, Library (Lib) Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Leeward, cheryl.sabella, christian.heimes, docs@python, r.david.murray, torim, vstinner
Priority: normal Keywords:

Created on 2013-07-04 07:55 by Leeward, last changed 2018-02-22 22:32 by cheryl.sabella. This issue is now closed.

Messages (9)
msg192276 - (view) Author: (Leeward) Date: 2013-07-04 07:55
As far as we could tell this bug is only consistently reproducible on Ubuntu 13.04.

A line in pydoc.py causes a segfault when help(numpy) (no other libraries that I know of) exits. The offending method is pipepager().

For a full trackdown and workaround of the problem see http://stackoverflow.com/questions/17344974/python-helpnumpy-causes-segfault-on-exit
msg192278 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2013-07-04 08:07
Please provide more information about your setup. Not everybody has access to a Ubuntu 13.04 box

* exact Python version
* NumPy version
* platform (X86, X86_64, ARM)
* Kernel, libc and compiler version are useful, too
* terminal application
* environment variables (output of ``export``, you may want to strip sensible values like DBus address). Especially TERM, PAGER and all LESS* variables are of interest.
msg192279 - (view) Author: (Leeward) Date: 2013-07-04 08:33
I'm no expert, I just found the bug... but I'll try my best.

* exact Python version: 2.7.4 (GCC 4.7.3)
* NumPy version: 1.7.1
* platform (X86, X86_64, ARM): i686
* Kernel: Linux 3.8.0-25-generic #37-Ubuntu SMP Thu Jun 6 20:47:30 UTC 2013 i686 i686 i686 GNU/Linux
* libc: ldd (Ubuntu EGLIBC 2.17-0ubuntu5) 2.17
* compiler: gcc version 4.7.3 (Ubuntu/Linaro 4.7.3-1ubuntu1)
* terminal application: not sure what you mean
* environment variables:
    TERM="xterm"
    (PAGER is not present)
    LESSCLOSE="/usr/bin/lesspipe %s %s"
    LESSOPEN="| /usr/bin/lesspipe %s"

If you need anything else please let me know.
msg192292 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2013-07-04 14:22
pydoc doesn't do anything special other than import the module.  Well, there's some special code in linecache for getting docstrings from C modules, I think, so that could be something to check. 

Does Ubuntu have local patches to numpy?
msg192293 - (view) Author: (Leeward) Date: 2013-07-04 14:50
Apparently it only occurs with the Ubuntu packaged versions of Python and numpy. Somebody who was able to reproduce my problem had it with python-2.7.4-0ubuntu1-amd64 and python-numpy-1:1.7.1-1ubuntu1-amd64 which exhibited the same behaviour. Apparently python-dbg and python-numpy-dbg do not reproduce the error.
msg192336 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2013-07-05 17:02
> For a full trackdown and workaround of the problem see http://stackoverflow.com/questions/17344974/python-helpnumpy-causes-segfault-on-exit

The gdb trace is not interesting because it stopped at SIGPIPE, which is not an error. Please rerun your program in gdb and ignore SIGPIPE (type "handle SIGPIPE noprint nostop") or continue on PIPE (type "cont"). Then when you get the crash, please copy/paste the gdb traceback here.
msg192631 - (view) Author: (Leeward) Date: 2013-07-08 08:50
This is what I get from gdb:

marzul@Leeward:~$ gdb --args python test.py
GNU gdb (GDB) 7.5.91.20130417-cvs-ubuntu
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /usr/bin/python2.7...(no debugging symbols found)...done.
(gdb) run
Starting program: /usr/bin/python2.7 test.py
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/i386-linux-gnu/libthread_db.so.1".

Program received signal SIGPIPE, Broken pipe.
0xb7fdd424 in __kernel_vsyscall ()
(gdb) cont
Continuing.

Program received signal SIGPIPE, Broken pipe.
0xb7fdd424 in __kernel_vsyscall ()
(gdb) cont
Continuing.

Program received signal SIGSEGV, Segmentation fault.
0xb7e518fc in ?? () from /lib/i386-linux-gnu/libc.so.6
(gdb) cont
Continuing.

Program terminated with signal SIGSEGV, Segmentation fault.
The program no longer exists.
(gdb) run
Starting program: /usr/bin/python2.7 test.py
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/i386-linux-gnu/libthread_db.so.1".

Program received signal SIGPIPE, Broken pipe.
0xb7fdd424 in __kernel_vsyscall ()
(gdb) cont
Continuing.

Program received signal SIGPIPE, Broken pipe.
0xb7fdd424 in __kernel_vsyscall ()
(gdb) cont
Continuing.

Program received signal SIGSEGV, Segmentation fault.
0xb7e518fc in ?? () from /lib/i386-linux-gnu/libc.so.6
(gdb) where
#0  0xb7e518fc in ?? () from /lib/i386-linux-gnu/libc.so.6
#1  0xb7e45e7c in _IO_default_xsputn () from /lib/i386-linux-gnu/libc.so.6
#2  0xb7e443a1 in _IO_file_xsputn () from /lib/i386-linux-gnu/libc.so.6
#3  0xb7e39025 in fwrite () from /lib/i386-linux-gnu/libc.so.6
#4  0x080ac05b in ?? ()
#5  0x080b6bde in PyEval_EvalFrameEx ()
#6  0x080b71c0 in PyEval_EvalFrameEx ()
#7  0x0811f939 in PyEval_EvalCodeEx ()
#8  0x080b80d4 in PyEval_EvalFrameEx ()
#9  0x080b71c0 in PyEval_EvalFrameEx ()
#10 0x0811f939 in PyEval_EvalCodeEx ()
#11 0x080b7265 in PyEval_EvalFrameEx ()
#12 0x080b71c0 in PyEval_EvalFrameEx ()
#13 0x0811f939 in PyEval_EvalCodeEx ()
#14 0x081203ee in ?? ()
#15 0x080e11f9 in ?? ()
#16 0x080e3daf in PyObject_Call ()
#17 0x08129483 in ?? ()
#18 0x080b8a3e in PyEval_EvalFrameEx ()
#19 0x0811f939 in PyEval_EvalCodeEx ()
#20 0x0812029e in ?? ()
#21 0x080e11f9 in ?? ()
#22 0x080e3daf in PyObject_Call ()
---Type <return> to continue, or q <return> to quit---
#23 0x0816dd88 in ?? ()
#24 0x080b7615 in PyEval_EvalFrameEx ()
#25 0x0811f939 in PyEval_EvalCodeEx ()
#26 0x081836c7 in PyEval_EvalCode ()
#27 0x08183b7d in ?? ()
#28 0x080a6032 in PyRun_FileExFlags ()
#29 0x080a65f8 in PyRun_SimpleFileExFlags ()
#30 0x080a74af in Py_Main ()
#31 0x080a7581 in main ()
(gdb)
msg193082 - (view) Author: Torim (torim) Date: 2013-07-15 09:15
I would add even the linked solution from StackOverflow.com does not work reliably for me. Try to get at the end of numpy document - text vanishes and possibly lose chars displaying in terminal. Need to reset it.

Modified pydoc's pipepager method this way:
def pipepager(text, cmd):
    """Page through text by feeding it to another program."""
    #pipe = os.popen(cmd, 'w')
    import subprocess
    pipep = subprocess.Popen(cmd, stdin=subprocess.PIPE, shell=True)
    try:
        #pipe.write(text)
        #pipe.close()
	pipep.communicate(text)
    except IOError:
        pass # Ignore broken pipes caused by quitting the pager program.


Works for me so far, although the exact cause of issue with the stock/default pydoc is still not known.
msg312599 - (view) Author: Cheryl Sabella (cheryl.sabella) * (Python triager) Date: 2018-02-22 22:32
It appears that the suggested change from SO was implemented under issue23374 and issue23792.  I cannot recreate this on Ubuntu 16.04, so closing as resolved.
History
Date User Action Args
2018-02-22 22:32:40cheryl.sabellasetstatus: open -> closed

assignee: docs@python ->

nosy: + cheryl.sabella
messages: + msg312599
resolution: fixed
stage: resolved
2013-07-15 09:15:59torimsetnosy: + torim
messages: + msg193082
components: + Library (Lib)
2013-07-14 19:17:54ned.deilylinkissue18447 superseder
2013-07-08 08:50:22Leewardsetmessages: + msg192631
2013-07-05 17:02:58vstinnersetmessages: + msg192336
2013-07-05 17:01:26vstinnersetnosy: + vstinner
2013-07-04 14:50:39Leewardsetmessages: + msg192293
2013-07-04 14:22:52r.david.murraysetnosy: + r.david.murray
messages: + msg192292
2013-07-04 08:33:28Leewardsetmessages: + msg192279
components: + Documentation, - Library (Lib)
versions: - 3rd party
2013-07-04 08:07:29christian.heimessetversions: + 3rd party
nosy: + christian.heimes

messages: + msg192278

components: + Library (Lib), - Documentation
2013-07-04 07:55:20Leewardcreate