4

I have strange problem, when I run python shell:

$ python3

Python 3.4.2 (default, Oct  8 2014, 10:45:20) 
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print('Hello') # Error appears for any command in shell

[1]    9021 segmentation fault  python3

But when I run python3 hello.py it works.

I've already tried python2.7, python3.4 and python3.5 and got the same error.

OS Debian 8.4

Update 1

journalctl output:

-- Logs begin at нд 2016-05-22 14:57:54 EEST, end at вт 2016-05-24 15:56:53 EEST. --
тра 24 15:56:53 desktop kernel: python[21150]: segfault at 0 ip           (null) sp 00007ffda62fe218 error 14 in python3[400000+3b2000]

Update 2

Problem still not solved, but I found that it works properly if I run it as another user. I've already tried to remove .cache and some python related directories (.jupyter, .ipython), but it makes no result.

Update 3

GDB output

gdb python
GNU gdb (Debian 7.7.1+dfsg-5) 7.7.1
Copyright (C) 2014 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 "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from python...(no debugging symbols found)...done.
(gdb) run
Starting program: /usr/bin/python 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Python 2.7.9 (default, Mar  1 2015, 12:57:24) 
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print("Hello")


Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
(gdb) 
(gdb) backtrace
#0  0x0000000000000000 in ?? ()
#1  0x00007ffff694892e in rl_callback_read_char () from /lib/x86_64-linux-gnu/libreadline.so.6
#2  0x00007ffff6b67cd5 in ?? () from /usr/lib/python2.7/lib-dynload/readline.x86_64-linux-gnu.so
#3  0x0000000000449d88 in PyOS_Readline ()
#4  0x0000000000422d2a in ?? ()
#5  0x00000000004c4e8a in ?? ()
#6  0x00000000004c460e in PyParser_ASTFromFile ()
#7  0x0000000000449b11 in PyRun_InteractiveOneFlags ()
#8  0x0000000000449937 in PyRun_InteractiveLoopFlags ()
#9  0x000000000042d96b in ?? ()
#10 0x00000000004982f2 in Py_Main ()
#11 0x00007ffff6f12b45 in __libc_start_main (main=0x497d80 <main>, argc=1, argv=0x7fffffffe748, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffe738) at libc-start.c:287
#12 0x0000000000497ca0 in _start ()
(gdb) 

Update 4

Strace debug for following actions:

python
Python 2.7.9 (default, Mar  1 2015, 12:57:24) 
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print("Hello")

[1]    17271 segmentation fault  python

And strace log:

 strace -p 17271
Process 17271 attached
select(1, [0], NULL, NULL, NULL)        = 1 (in [0])
rt_sigaction(SIGWINCH, {0x7fd8ff2f8270, [], SA_RESTORER|SA_RESTART, 0x7fd9005a58d0}, {SIG_DFL, [], 0}, 8) = 0
read(0, "p", 1)                         = 1
write(1, "p", 1)                        = 1
rt_sigaction(SIGWINCH, {SIG_DFL, [], SA_RESTORER, 0x7fd9005a58d0}, {0x7fd8ff2f8270, [], SA_RESTORER|SA_RESTART, 0x7fd9005a58d0}, 8) = 0
select(1, [0], NULL, NULL, NULL)        = 1 (in [0])
rt_sigaction(SIGWINCH, {0x7fd8ff2f8270, [], SA_RESTORER|SA_RESTART, 0x7fd9005a58d0}, {SIG_DFL, [], SA_RESTORER, 0x7fd9005a58d0}, 8) = 0
read(0, "r", 1)                         = 1
write(1, "r", 1)                        = 1
rt_sigaction(SIGWINCH, {SIG_DFL, [], SA_RESTORER, 0x7fd9005a58d0}, {0x7fd8ff2f8270, [], SA_RESTORER|SA_RESTART, 0x7fd9005a58d0}, 8) = 0
select(1, [0], NULL, NULL, NULL)        = 1 (in [0])
rt_sigaction(SIGWINCH, {0x7fd8ff2f8270, [], SA_RESTORER|SA_RESTART, 0x7fd9005a58d0}, {SIG_DFL, [], SA_RESTORER, 0x7fd9005a58d0}, 8) = 0
read(0, "i", 1)                         = 1
write(1, "i", 1)                        = 1
rt_sigaction(SIGWINCH, {SIG_DFL, [], SA_RESTORER, 0x7fd9005a58d0}, {0x7fd8ff2f8270, [], SA_RESTORER|SA_RESTART, 0x7fd9005a58d0}, 8) = 0
select(1, [0], NULL, NULL, NULL)        = 1 (in [0])
rt_sigaction(SIGWINCH, {0x7fd8ff2f8270, [], SA_RESTORER|SA_RESTART, 0x7fd9005a58d0}, {SIG_DFL, [], SA_RESTORER, 0x7fd9005a58d0}, 8) = 0
read(0, "n", 1)                         = 1
write(1, "n", 1)                        = 1
rt_sigaction(SIGWINCH, {SIG_DFL, [], SA_RESTORER, 0x7fd9005a58d0}, {0x7fd8ff2f8270, [], SA_RESTORER|SA_RESTART, 0x7fd9005a58d0}, 8) = 0
select(1, [0], NULL, NULL, NULL)        = 1 (in [0])
rt_sigaction(SIGWINCH, {0x7fd8ff2f8270, [], SA_RESTORER|SA_RESTART, 0x7fd9005a58d0}, {SIG_DFL, [], SA_RESTORER, 0x7fd9005a58d0}, 8) = 0
read(0, "t", 1)                         = 1
write(1, "t", 1)                        = 1
rt_sigaction(SIGWINCH, {SIG_DFL, [], SA_RESTORER, 0x7fd9005a58d0}, {0x7fd8ff2f8270, [], SA_RESTORER|SA_RESTART, 0x7fd9005a58d0}, 8) = 0
select(1, [0], NULL, NULL, NULL)        = 1 (in [0])
rt_sigaction(SIGWINCH, {0x7fd8ff2f8270, [], SA_RESTORER|SA_RESTART, 0x7fd9005a58d0}, {SIG_DFL, [], SA_RESTORER, 0x7fd9005a58d0}, 8) = 0
read(0, "(", 1)                         = 1
write(1, "(", 1)                        = 1
rt_sigaction(SIGWINCH, {SIG_DFL, [], SA_RESTORER, 0x7fd9005a58d0}, {0x7fd8ff2f8270, [], SA_RESTORER|SA_RESTART, 0x7fd9005a58d0}, 8) = 0
select(1, [0], NULL, NULL, NULL)        = 1 (in [0])
rt_sigaction(SIGWINCH, {0x7fd8ff2f8270, [], SA_RESTORER|SA_RESTART, 0x7fd9005a58d0}, {SIG_DFL, [], SA_RESTORER, 0x7fd9005a58d0}, 8) = 0
read(0, ")", 1)                         = 1
write(1, ")", 1)                        = 1
rt_sigaction(SIGWINCH, {SIG_DFL, [], SA_RESTORER, 0x7fd9005a58d0}, {0x7fd8ff2f8270, [], SA_RESTORER|SA_RESTART, 0x7fd9005a58d0}, 8) = 0
select(1, [0], NULL, NULL, NULL)        = 1 (in [0])
rt_sigaction(SIGWINCH, {0x7fd8ff2f8270, [], SA_RESTORER|SA_RESTART, 0x7fd9005a58d0}, {SIG_DFL, [], SA_RESTORER, 0x7fd9005a58d0}, 8) = 0
read(0, "\33", 1)                       = 1
rt_sigaction(SIGWINCH, {SIG_DFL, [], SA_RESTORER, 0x7fd9005a58d0}, {0x7fd8ff2f8270, [], SA_RESTORER|SA_RESTART, 0x7fd9005a58d0}, 8) = 0
select(1, [0], NULL, NULL, NULL)        = 1 (in [0])
rt_sigaction(SIGWINCH, {0x7fd8ff2f8270, [], SA_RESTORER|SA_RESTART, 0x7fd9005a58d0}, {SIG_DFL, [], SA_RESTORER, 0x7fd9005a58d0}, 8) = 0
read(0, "[", 1)                         = 1
rt_sigaction(SIGWINCH, {SIG_DFL, [], SA_RESTORER, 0x7fd9005a58d0}, {0x7fd8ff2f8270, [], SA_RESTORER|SA_RESTART, 0x7fd9005a58d0}, 8) = 0
select(1, [0], NULL, NULL, NULL)        = 1 (in [0])
rt_sigaction(SIGWINCH, {0x7fd8ff2f8270, [], SA_RESTORER|SA_RESTART, 0x7fd9005a58d0}, {SIG_DFL, [], SA_RESTORER, 0x7fd9005a58d0}, 8) = 0
read(0, "D", 1)                         = 1
write(1, "\10", 1)                      = 1
rt_sigaction(SIGWINCH, {SIG_DFL, [], SA_RESTORER, 0x7fd9005a58d0}, {0x7fd8ff2f8270, [], SA_RESTORER|SA_RESTART, 0x7fd9005a58d0}, 8) = 0
select(1, [0], NULL, NULL, NULL)        = 1 (in [0])
rt_sigaction(SIGWINCH, {0x7fd8ff2f8270, [], SA_RESTORER|SA_RESTART, 0x7fd9005a58d0}, {SIG_DFL, [], SA_RESTORER, 0x7fd9005a58d0}, 8) = 0
read(0, "\"", 1)                        = 1
write(1, "\")\10", 3)                   = 3
rt_sigaction(SIGWINCH, {SIG_DFL, [], SA_RESTORER, 0x7fd9005a58d0}, {0x7fd8ff2f8270, [], SA_RESTORER|SA_RESTART, 0x7fd9005a58d0}, 8) = 0
select(1, [0], NULL, NULL, NULL)        = 1 (in [0])
rt_sigaction(SIGWINCH, {0x7fd8ff2f8270, [], SA_RESTORER|SA_RESTART, 0x7fd9005a58d0}, {SIG_DFL, [], SA_RESTORER, 0x7fd9005a58d0}, 8) = 0
read(0, "\"", 1)                        = 1
write(1, "\")\10", 3)                   = 3
rt_sigaction(SIGWINCH, {SIG_DFL, [], SA_RESTORER, 0x7fd9005a58d0}, {0x7fd8ff2f8270, [], SA_RESTORER|SA_RESTART, 0x7fd9005a58d0}, 8) = 0
select(1, [0], NULL, NULL, NULL)        = 1 (in [0])
rt_sigaction(SIGWINCH, {0x7fd8ff2f8270, [], SA_RESTORER|SA_RESTART, 0x7fd9005a58d0}, {SIG_DFL, [], SA_RESTORER, 0x7fd9005a58d0}, 8) = 0
read(0, "\33", 1)                       = 1
rt_sigaction(SIGWINCH, {SIG_DFL, [], SA_RESTORER, 0x7fd9005a58d0}, {0x7fd8ff2f8270, [], SA_RESTORER|SA_RESTART, 0x7fd9005a58d0}, 8) = 0
select(1, [0], NULL, NULL, NULL)        = 1 (in [0])
rt_sigaction(SIGWINCH, {0x7fd8ff2f8270, [], SA_RESTORER|SA_RESTART, 0x7fd9005a58d0}, {SIG_DFL, [], SA_RESTORER, 0x7fd9005a58d0}, 8) = 0
read(0, "[", 1)                         = 1
rt_sigaction(SIGWINCH, {SIG_DFL, [], SA_RESTORER, 0x7fd9005a58d0}, {0x7fd8ff2f8270, [], SA_RESTORER|SA_RESTART, 0x7fd9005a58d0}, 8) = 0
select(1, [0], NULL, NULL, NULL)        = 1 (in [0])
rt_sigaction(SIGWINCH, {0x7fd8ff2f8270, [], SA_RESTORER|SA_RESTART, 0x7fd9005a58d0}, {SIG_DFL, [], SA_RESTORER, 0x7fd9005a58d0}, 8) = 0
read(0, "D", 1)                         = 1
write(1, "\10", 1)                      = 1
rt_sigaction(SIGWINCH, {SIG_DFL, [], SA_RESTORER, 0x7fd9005a58d0}, {0x7fd8ff2f8270, [], SA_RESTORER|SA_RESTART, 0x7fd9005a58d0}, 8) = 0
select(1, [0], NULL, NULL, NULL)        = 1 (in [0])
rt_sigaction(SIGWINCH, {0x7fd8ff2f8270, [], SA_RESTORER|SA_RESTART, 0x7fd9005a58d0}, {SIG_DFL, [], SA_RESTORER, 0x7fd9005a58d0}, 8) = 0
read(0, "H", 1)                         = 1
write(1, "H\")\10\10", 5)               = 5
rt_sigaction(SIGWINCH, {SIG_DFL, [], SA_RESTORER, 0x7fd9005a58d0}, {0x7fd8ff2f8270, [], SA_RESTORER|SA_RESTART, 0x7fd9005a58d0}, 8) = 0
select(1, [0], NULL, NULL, NULL)        = 1 (in [0])
rt_sigaction(SIGWINCH, {0x7fd8ff2f8270, [], SA_RESTORER|SA_RESTART, 0x7fd9005a58d0}, {SIG_DFL, [], SA_RESTORER, 0x7fd9005a58d0}, 8) = 0
read(0, "e", 1)                         = 1
write(1, "e\")\10\10", 5)               = 5
rt_sigaction(SIGWINCH, {SIG_DFL, [], SA_RESTORER, 0x7fd9005a58d0}, {0x7fd8ff2f8270, [], SA_RESTORER|SA_RESTART, 0x7fd9005a58d0}, 8) = 0
select(1, [0], NULL, NULL, NULL)        = 1 (in [0])
rt_sigaction(SIGWINCH, {0x7fd8ff2f8270, [], SA_RESTORER|SA_RESTART, 0x7fd9005a58d0}, {SIG_DFL, [], SA_RESTORER, 0x7fd9005a58d0}, 8) = 0
read(0, "l", 1)                         = 1
write(1, "l\")\10\10", 5)               = 5
rt_sigaction(SIGWINCH, {SIG_DFL, [], SA_RESTORER, 0x7fd9005a58d0}, {0x7fd8ff2f8270, [], SA_RESTORER|SA_RESTART, 0x7fd9005a58d0}, 8) = 0
select(1, [0], NULL, NULL, NULL)        = 1 (in [0])
rt_sigaction(SIGWINCH, {0x7fd8ff2f8270, [], SA_RESTORER|SA_RESTART, 0x7fd9005a58d0}, {SIG_DFL, [], SA_RESTORER, 0x7fd9005a58d0}, 8) = 0
read(0, "l", 1)                         = 1
write(1, "l\")\10\10", 5)               = 5
rt_sigaction(SIGWINCH, {SIG_DFL, [], SA_RESTORER, 0x7fd9005a58d0}, {0x7fd8ff2f8270, [], SA_RESTORER|SA_RESTART, 0x7fd9005a58d0}, 8) = 0
select(1, [0], NULL, NULL, NULL)        = 1 (in [0])
rt_sigaction(SIGWINCH, {0x7fd8ff2f8270, [], SA_RESTORER|SA_RESTART, 0x7fd9005a58d0}, {SIG_DFL, [], SA_RESTORER, 0x7fd9005a58d0}, 8) = 0
read(0, "o", 1)                         = 1
write(1, "o\")\10\10", 5)               = 5
rt_sigaction(SIGWINCH, {SIG_DFL, [], SA_RESTORER, 0x7fd9005a58d0}, {0x7fd8ff2f8270, [], SA_RESTORER|SA_RESTART, 0x7fd9005a58d0}, 8) = 0
select(1, [0], NULL, NULL, NULL)        = 1 (in [0])
rt_sigaction(SIGWINCH, {0x7fd8ff2f8270, [], SA_RESTORER|SA_RESTART, 0x7fd9005a58d0}, {SIG_DFL, [], SA_RESTORER, 0x7fd9005a58d0}, 8) = 0
read(0, "\r", 1)                        = 1
rt_sigaction(SIGWINCH, {SIG_DFL, [], SA_RESTORER, 0x7fd9005a58d0}, {0x7fd8ff2f8270, [], SA_RESTORER|SA_RESTART, 0x7fd9005a58d0}, 8) = 0
select(1, [0], NULL, NULL, NULL)        = 1 (in [0])
rt_sigaction(SIGWINCH, {0x7fd8ff2f8270, [], SA_RESTORER|SA_RESTART, 0x7fd9005a58d0}, {SIG_DFL, [], SA_RESTORER, 0x7fd9005a58d0}, 8) = 0
read(0, "\r", 1)                        = 1
write(1, "\n", 1)                       = 1
ioctl(0, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B38400 opost isig -icanon -echo ...}) = 0
ioctl(0, SNDCTL_TMR_STOP or SNDRV_TIMER_IOCTL_GINFO or TCSETSW, {B38400 opost isig icanon echo ...}) = 0
ioctl(0, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
rt_sigaction(SIGWINCH, {SIG_DFL, [], SA_RESTORER, 0x7fd9005a58d0}, {0x7fd8ff2f8270, [], SA_RESTORER|SA_RESTART, 0x7fd9005a58d0}, 8) = 0
select(1, [0], NULL, [0], {0, 500000})  = 0 (Timeout)
write(1, "\n", 1)                       = 1
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0} ---
+++ killed by SIGSEGV +++

Update 5

Environmental variables diff (works well with root user):

Environmental variables diff

Update 6

As normal user:

ldd /usr/bin/python
    linux-vdso.so.1 (0x00007ffcb1648000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f316da1d000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f316d815000)
    libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007f316d60d000)
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f316d3ed000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f316d0e5000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f316cd35000)
    /lib64/ld-linux-x86-64.so.2 (0x000055ca7cb3e000)

As root:

ldd /usr/bin/python
    linux-vdso.so.1 (0x00007fffc8ef0000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f79bf425000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f79bf21d000)
    libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007f79bf015000)
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f79bedf5000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f79beaed000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f79be73d000)
    /lib64/ld-linux-x86-64.so.2 (0x00005600afb99000)
Anton Linevych
  • 647
  • 1
  • 7
  • 25
  • 1
    I add something close once, the problem was that, for some occult reason, some .pyc files in /usr/lib/ got corrupted. Deleting them all solved the problem. – polku May 24 '16 at 12:18
  • I've done `cd /usr/lib && sudo find . -name "*.pyc" -exec rm -rf {} \;` it removes all *.pyc files, but it doesn't solve the problem. – Anton Linevych May 24 '16 at 12:46
  • 1
    did you check shell variables $PYTHONPATH and $PYTHONSTARTUP ? maybe they are pointing to some dirs with nasty *.pyc? – claperius Aug 11 '16 at 12:41
  • 1
    Could this be a problem external to python? Have you tried using a different shell or terminal program? What output do you get if you run python with `gdb`? – YellowBird Aug 11 '16 at 12:45
  • @YellowBird Changing shells or terminals doesn't help, but if switch user `sudo su && python` it works properly. GDB — see update 3 section. – Anton Linevych Aug 11 '16 at 13:09
  • @Mikolaj `echo $PYTHONSTARTUP && echo $PYTHONPATH` return blank values. – Anton Linevych Aug 11 '16 at 13:11
  • Have you tried using an alternative python runtime, perhaps written in another language? Python has many runtimes. Segfaults usually occur for me on machines lacking in resources, so maybe a more lightweight python implementation would help. It could simply be a response to permissions problem – MrMesees Aug 11 '16 at 14:23
  • @MrMesees AMD FX-6300 6 cores and 16 GB RAM... – Anton Linevych Aug 11 '16 at 14:34
  • 1
    since the same python is working on the other user's account, maybe comparing environment variables would give some hints? as user1: env > /tmp/user1env.txt then as user2: env > /tmp/user2env.txt then, diff.... – claperius Aug 11 '16 at 15:24
  • @Mikolaj Looks likes nothing special (see Update 5 section) – Anton Linevych Aug 11 '16 at 16:27
  • 2
    The program is crashing when it tries to print to stdout - see last line before segfault in strace output - are there any MAC type security controls enabled for that user that could be stopping it from writing to stdout? – danny Aug 12 '16 at 10:18
  • 1
    A backtrace from GDB would be useful. Also, I'd try to specifically clean all the environment variables and run interactive python then. – Roman Khimov Aug 14 '16 at 09:05
  • @RomanKhimov `env -i python` has the same result. – Anton Linevych Aug 15 '16 at 23:54
  • @danny I don't installed any security tools... – Anton Linevych Aug 15 '16 at 23:55
  • Again, a backtrace from GDB would be useful. Also, maybe `ldd /usr/bin/python` from both users will tell us something? – Roman Khimov Aug 16 '16 at 06:25
  • @RomanKhimov GDB — update 3, `ldd /usr/bin/python` — update 6. – Anton Linevych Aug 16 '16 at 09:33
  • [Backtrace](https://sourceware.org/gdb/onlinedocs/gdb/Backtrace.html) is still missing. – Roman Khimov Aug 16 '16 at 09:37
  • @RomanKhimov Ah, sorry, I haven't work with GDB before :) I've updated section "Update 3" with backtrace. – Anton Linevych Aug 16 '16 at 10:23
  • 1
    Do you have any `~/.inputrc`? – Roman Khimov Aug 16 '16 at 10:45
  • @RomanKhimov you are my hero! I just removed `~/.inputrc` and everything works. Please write this comment as answer to get bounty points :) – Anton Linevych Aug 16 '16 at 22:30
  • 1
    I think if you still have this file around, it would be useful to also post it here, just for everyone to know (and be able to google) what kind of setup can result in this behaviour. – Roman Khimov Aug 17 '16 at 04:34

3 Answers3

7

So, after some debugging (although comments now look more like a chat, they can be useful as an example of debugging session) it was found that the segfault occured because of some problem with the readline setup, namely user-specific ~/.inputrc configuration file (and I would say that it probably is a readline bug, because whatever the configuration is, it shouldn't segfault).

This shows how complicated and fragile our software is, because it's not obvious at first glance that the python could collapse that way because of broken configuration file for a library that not many even remember python uses (if they even remember it exists).

Roman Khimov
  • 4,807
  • 1
  • 27
  • 35
3

Segmentation Error can have a lot of Reasons.

For example:

  • Low memory
  • Faulty Ram memory
  • Fetching huge data bigger than swap mem
  • buggy code
  • multiple recursion

Because you are just trying to print something I would say it can be reason 1 or 2.

mnille
  • 1,328
  • 4
  • 16
  • 20
  • 1
    I have 16 Gb of Ram and everything works perfect. It's definitly **non-hardware** problem, because python shell works as `root` or any other user excepting my main one. Please read comments to my question, and thanks for an answer! – Anton Linevych Aug 16 '16 at 12:00
1

I had the same issue and I resolve it by changing the LC_CTYPE env variable from iso to utf8.