[Answer]-"from __future__ import unicode_literals" gives segfault in python 2.7

1👍

To solve your current issue you can place a u before each used string literal, so out of 'foo' make u'foo' etc. This of course can be a lot of code to change, BUT:

Segmentation Faults are always a problem within the implementation of Python (either the core language interpreter or a module in use). There is no way within the Python language to produce a Segmentation Fault because this kind of memory management is hidden from the Python developer.

This means that this kind of bug needs to be fixed within the implementation of the Python language or module. You should provide your information as a bug report to the developers of the faulty code. The faulty code can be be found by producing a core file and analyzing this. It is a lucky coincidence that you can reproduce the problem so easily, so you can configure your shell to produce core files:

$ ulimit -c unlimited

Then produce the Segfault:

$ python
>>> from __future__ import unicode_literals
Segmentation fault (core dumped)

Now you should have a core file and can load this in the Gnu debugger:

$ gdb /usr/bin/python core   # maybe adjust path-to-python for your system
GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04
...
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `python'.
Program terminated with signal 11, Segmentation fault.
#0  0x00007f21c08705d5 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
(gdb)

Or something like this. Then type:

(gdb) bt

This will print a large backtrace of the situation which lead to the Segfault (frame #0 will be the one who raised the problem, frame #1 called frame #0 etc., so this backtrace is innermost-first). Maybe you can figure out by the names of the functions etc. which module is involved. Then you should provide this backtrace to the developers of the involved module. They are the ones to solve the issue at hand.

👤Alfe

Leave a comment