所有〜
当我尝试在webapp中使用rest_framework时发生了段错误:
from rest_framework import viewsets
最后,我指出了这里出现的问题:
>>> from __future__ import unicode_literals
Segmentation fault
但我不知道下一个,所以我在这里发布了一些帮助。 thx任何建议。
供参考:
我将一个正常的__future__.py与这个有问题的__future__.py进行了比较。但我一无所获
2.我尝试过不同版本的django-rest-framework,所以我可以得到上面的piont。
有些东西可能有用:
平台:Linux 3.2.12-gentoo#1 SMP
python:Python 2.7.3(默认,2012年10月8日,16:37:44)[gCC 4.4.5] on linux2
######更新信息。对于U来说真的是thx; - )########
核心细节:
# gdb python core
GNU gdb (Gentoo 7.3.1 p2) 7.3.1
Copyright (C) 2011 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-pc-linux-gnu".
For bug reporting instructions, please see:
<http://bugs.gentoo.org/>...
Reading symbols from /bin/python...done.
[New LWP 6349]
warning: Can't read pathname for load map: Input/output error.
[Thread debugging using libthread_db enabled]
Core was generated by `python'.
Program terminated with signal 11, Segmentation fault.
#0 binary_iop1 (op_slot=<optimized out>, iop_slot=<optimized out>, w=<optimized
1280 Objects/abstract.c: No such file or directory.
in Objects/abstract.c
(gdb) bt
#0 binary_iop1 (op_slot=<optimized out>, iop_slot=<optimized out>, w=<optimized out>, v=<optimized out>) at Objects/abstract.c:1280
#1 binary_iop (op_name=<optimized out>, op_slot=<optimized out>, iop_slot=<optimized out>, w=<optimized out>, v=<optimized out>) at Objects/abstract.c:1298
#2 PyNumber_InPlaceTrueDivide (v=0x39, w=0xb76e03d0) at Objects/abstract.c:1332
#3 0x080e0f54 in PyEval_EvalFrameEx (f=0x88a1f7c, throwflag=0) at Python/ceval.c:1514
#4 0x080e6a44 in PyEval_EvalCodeEx (co=0xb751d9b0, globals=0xb757035c, locals=0xb757035c, args=0x0, argcount=0, kws=0x0, kwcount=0, defs=0x0, defcount=0, closure=0x0)
at Python/ceval.c:3263
#5 0x080e6b77 in PyEval_EvalCode (co=0xb751d9b0, globals=0xb757035c, locals=0xb757035c) at Python/ceval.c:669
#6 0x08103f27 in run_mod (arena=<optimized out>, flags=<optimized out>, locals=<optimized out>, globals=<optimized out>, filename=<optimized out>, mod=<optimized out>)
at Python/pythonrun.c:1353
#7 PyRun_InteractiveOneFlags (fp=0xb76df440, filename=0x815b7a4 "<stdin>", flags=0xbfbb23ec) at Python/pythonrun.c:852
#8 0x08104198 in PyRun_InteractiveLoopFlags (fp=0xb76df440, filename=0x815b7a4 "<stdin>", flags=0xbfbb23ec) at Python/pythonrun.c:772
#9 0x081049e5 in PyRun_AnyFileExFlags (fp=0xb76df440, filename=0x815b7a4 "<stdin>", closeit=0, flags=0xbfbb23ec) at Python/pythonrun.c:741
#10 0x0805bacd in Py_Main (argc=1, argv=0xbfbb24d4) at Modules/main.c:674
#11 0x0805abab in main (argc=1, argv=0xbfbb24d4) at ./Modules/python.c:23
(gdb)
答案 0 :(得分:1)
要解决当前问题,您可以在每个使用过的字符串文字之前放置u
,因此'foo'
生成u'foo'
等等。这当然可以改变很多代码,但是:
分段错误始终是Python实现中的一个问题(核心语言解释器或正在使用的模块)。 Python语言中没有办法产生分段错误,因为这种内存管理对Python开发人员是隐藏的。
这意味着需要在Python语言或模块的实现中修复此类错误。您应该将您的信息作为错误报告提供给错误代码的开发人员。可以通过生成核心文件并对其进行分析来找到错误的代码。您可以轻松地重现问题,这是一个幸运的巧合,因此您可以配置shell以生成核心文件:
$ ulimit -c unlimited
然后产生Segfault:
$ python
>>> from __future__ import unicode_literals
Segmentation fault (core dumped)
现在你应该有一个核心文件,可以在Gnu调试器中加载它:
$ 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)
或类似的东西。然后输入:
(gdb) bt
这将打印导致Segfault的情况的大型回溯(帧#0将是提出问题的帧,帧#1称为帧#0等,因此这种回溯是最里面的第一个)。也许您可以通过功能的名称等来确定哪个模块涉及到。然后,您应该向相关模块的开发人员提供此回溯。他们是解决手头问题的人。