This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Interpreter triggers segmentation fault at the starting
Type: crash Stage: resolved
Components: Interpreter Core Versions: Python 3.3, Python 3.4
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: mdootb, ned.deily, rhettinger, vstinner
Priority: normal Keywords:

Created on 2015-05-18 15:49 by mdootb, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (8)
msg243490 - (view) Author: doz (mdootb) Date: 2015-05-18 15:49
Hello,

Python 3.4.2 triggers  a segmentation fault  at the starting on my ARM9 platform. 
Crash occurs  also with 3.3.  The version 2.7 don't crash and seems to work correctly
System is built with buildroot-2015.02 and gcc  4.2.1.  
Fault is always reproducible.

Please find the following information about the crash and the conditions. 
Do you know restrictions with old kernel version and python ?

On target :
# uname -a
Linux buildroot 2.6.30.10 #mvl-avb-0.8 Mon May 18 16:02:40 CEST 2015 armv5tejl GNU/Linux  
# python --version
Python 3.4.2
 
# python
Segmentation fault (core dumped)

on host, I analyze core dump 

$ arm-none-linux-gnueabi-gdb -ex 'set sysroot .' -ex 'core-file ./core' usr/bin/python
GNU gdb (CodeSourcery Sourcery G++ Lite 2007q3-51) 6.6.50.20070821-cvs
Copyright (C) 2007 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "--host=i686-pc-linux-gnu --target=arm-none-linux-gnueabi".
For bug reporting instructions, please see:
<https://support.codesourcery.com/GNUToolchain/>.
..
Reading symbols from /home/xxx/projects/YYY/buildroot-2015.02/output/target/usr/lib/libpython3.4m.so.1.0...done.
Loaded symbols for ./usr/lib/libpython3.4m.so.1.0
Reading symbols from /home/xxx/projects/YYY/buildroot-2015.02/output/target/lib/libpthread.so.0...done.
Loaded symbols for ./lib/libpthread.so.0
Reading symbols from /home/xxx/projects/YYY/buildroot-2015.02/output/target/lib/libdl.so.2...done.
Loaded symbols for ./lib/libdl.so.2
Reading symbols from /home/xxx/projects/YYY/buildroot-2015.02/output/target/lib/libutil.so.1...done.
Loaded symbols for ./lib/libutil.so.1
Reading symbols from /home/xxx/projects/YYY/buildroot-2015.02/output/target/lib/libm.so.6...done.
Loaded symbols for ./lib/libm.so.6
Reading symbols from /home/xxx/projects/YYY/buildroot-2015.02/output/target/lib/libc.so.6...done.
Loaded symbols for ./lib/libc.so.6
Reading symbols from /home/xxx/projects/YYY/buildroot-2015.02/output/target/lib/libgcc_s.so.1...done.
Loaded symbols for ./lib/libgcc_s.so.1
Reading symbols from /home/xxx/projects/YYY/buildroot-2015.02/output/target/lib/ld-linux.so.3...done.
Loaded symbols for ./lib/ld-linux.so.3
Core was generated by `python'.
Program terminated with signal 11, Segmentation fault.
#0  insertdict (mp=0x4041e058, key=0x4041f020, hash=1075606564, value=0x4041d540) at Objects/dictobject.c:824
824	        Py_DECREF(old_value); /* which **CAN** re-enter (see issue #22653) */
(gdb) bt
#0  insertdict (mp=0x4041e058, key=0x4041f020, hash=1075606564, value=0x4041d540) at Objects/dictobject.c:824
#1  0x400a3be0 in add_subclass (base=<value optimized out>, type=0x401c7424) at Objects/typeobject.c:4789
#2  0x400abb18 in PyType_Ready (type=0x401c7424) at Objects/typeobject.c:4745
#3  0x40094534 in _Py_ReadyTypes () at Objects/object.c:1546
#4  0x40116aec in _Py_InitializeEx_Private (install_sigs=1, install_importlib=1) at Python/pythonrun.c:382
#5  0x401263a8 in Py_Main (argc=1076832428, argv=0x11008) at Modules/main.c:654
#6  0x000088f4 in main (argc=1, argv=0x402fb844) at ./Modules/python.c:69

(gdb) info locals
old_value = (PyObject *) 0x1
value_addr = (PyObject **) 0x400a3be0
ep = (PyDictKeyEntry *) 0x11390

(gdb) list
819	    MAINTAIN_TRACKING(mp, key, value);
820	    old_value = *value_addr;
821	    if (old_value != NULL) {
822	        assert(ep->me_key != NULL && ep->me_key != dummy);
823	        *value_addr = value;
824	        Py_DECREF(old_value); /* which **CAN** re-enter (see issue #22653) */
825	    }
826	    else {
827	        if (ep->me_key == NULL) {
828	            Py_INCREF(key);

./arm-none-linux-gnueabi-gcc --version
arm-none-linux-gnueabi-gcc (CodeSourcery Sourcery G++ Lite 2007q3-51) 4.2.1
Copyright (C) 2007 Free Software Foundation, Inc.

Thank your for your help
msg243491 - (view) Author: doz (mdootb) Date: 2015-05-18 15:51
I already try to apply patches from http://bugs.python.org/issue22653 . It don't solve problem.
msg243522 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2015-05-18 19:08
Try building python with debug on:

./configure --with-pydebug [...]

Also, 3.4.2 has been replaced by 3.4.3 which includes the fixes from Issue22653.
msg243602 - (view) Author: doz (mdootb) Date: 2015-05-19 15:50
I manually disabled xxlimited (file xxlimited.c removed , and lines in setup.py  commented) because : 

In file included from ./Include/Python.h:68,
                 from xxxx/build/python3-3.4.2/Modules/xxlimited.c:17:
./Include/object.h:65:2: error: #error Py_LIMITED_API is incompatible with Py_DEBUG, Py_TRACE_REFS, and Py_REF_DEBUG

So python has been rebuilt with option  -with-pydebug 
Now, I don't have segfault thanks to assert of line 821

#python
python: Objects/dictobject.c:821: insertdict: Assertion `ep->me_key != ((void *)0) && ep->me_key != (&_dummy_struct)' failed.
Aborted

buildroot-2015.02 set the following configuration options :
./configure --target=arm-buildroot-linux-gnueabi --host=arm-buildroot-linux-gnueabi --build=x86_64-unknown-linux-gnu --prefix=/usr --exec-prefix=/usr --sysconfdir=/etc --localstatedir=/var --program-prefix=""     --enable-ipv6  --enable-shared  --disable-curses --with-libmpdec=none --with-expat=none --enable-old-stdlib-cache --disable-sqlite3 --disable-codecs-cjk --disable-ossaudiodev --with-pydebug --without-ensurepip --without-cxx-main --with-system-ffi --disable-pydoc --disable-test-modules --disable-lib2to3 --disable-tk --disable-nis --disable-idle3 –disable-pyo-build
msg243603 - (view) Author: doz (mdootb) Date: 2015-05-19 16:04
value of ep->me_key equals 0
msg243606 - (view) Author: doz (mdootb) Date: 2015-05-19 16:25
Problem also present with only configuration option :
 --enable-ipv6  --enable-shared  --disable-curses --with-libmpdec=none --with-expat=none --enable-old-stdlib-cache --disable-sqlite3 --disable-codecs-cjk --disable-ossaudiodev --with-pydebug
msg245065 - (view) Author: doz (mdootb) Date: 2015-06-09 14:05
The problem is only present with gcc optimization -Os . Not present with -O0 ,O1, O2, O3.

Do you have an idea of the gcc pass responsible to that ? 

(I have also a similar problem with openssl)

regards
msg368896 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-05-15 01:12
No activity since 2015, it was a bug in Python 3.4. Please retry with Python 3.8.3. I close the issue.
History
Date User Action Args
2022-04-11 14:58:17adminsetgithub: 68416
2020-05-15 01:12:17vstinnersetstatus: open -> closed

nosy: + vstinner
messages: + msg368896

resolution: third party -> out of date
stage: resolved
2015-06-09 14:05:15mdootbsetresolution: third party
messages: + msg245065
2015-05-19 17:29:59serhiy.storchakasetnosy: + rhettinger
2015-05-19 16:25:32mdootbsetmessages: + msg243606
2015-05-19 16:04:54mdootbsetmessages: + msg243603
2015-05-19 15:50:25mdootbsetmessages: + msg243602
2015-05-18 19:08:30ned.deilysetnosy: + ned.deily
messages: + msg243522
2015-05-18 15:51:59mdootbsetmessages: + msg243491
2015-05-18 15:49:39mdootbcreate