【问题标题】:mod-wsgi segmentation fault under debian/apache2debian/apache2 下的 mod-wsgi 分段错误
【发布时间】:2010-11-19 15:36:14
【问题描述】:

我正在尝试让 mod-wsgi 在 Apache2 下运行,并着眼于将它与 Django 一起使用。

现在我正在运行一个基本的应用程序,但遇到了分段错误。任何有关如何追踪错误的建议将不胜感激,我被卡住了。

这是在 Debian/Lenny、Apache、mod-wsgi 和 python 2.5 的股票版本下。我已经检查过 mod-wsgi 与 /usr/lib/libpython2.5.so.1.0 相关联。我最初安装了 python 2.4,但将其删除以防万一它选择了错误的版本。

脚本文件是:

def application(environ, start_response):
    status = '200 OK'
    output = 'Hello World!'

    response_headers = [('Content-type', 'text/plain'),
                        ('Content-Length', str(len(output)))]
    start_response(status, response_headers)

    return [output]

我的配置是:

WSGIScriptAlias /myapp /var/www/test/myapp.wsgi

<Directory /var/www/test/myapp.wsgi>
Order allow,deny
Allow from all
</Directory>

当我尝试查看 url 时,我在 apache 错误日志中看到了这一点。

[Fri Nov 19 09:29:58 2010] [info] mod_wsgi (pid=7190): Create interpreter 'morpheus.gateway.2wire.net|/myapp'.
[Fri Nov 19 09:29:58 2010] [info] mod_wsgi (pid=7331): Attach interpreter ''.
[Fri Nov 19 09:29:58 2010] [notice] child pid 7190 exit signal Segmentation fault (11)

Python 似乎工作正常,否则我已经在内置服务器下运行我的 django 应用程序,没有任何问题。

仅供参考,我开始尝试让我的 django 应用程序运行,但遇到了这个错误:

[Fri Nov 19 08:25:08 2010] [info] mod_wsgi (pid=6861): Create interpreter 'morpheus.gateway.2wire.net|/curtana'.
[Fri Nov 19 08:25:08 2010] [error] [client 192.168.2.70] mod_wsgi (pid=6861): Exception occurred processing WSGI script '/var/data/curtana/curtana.wsgi'.
[Fri Nov 19 08:25:08 2010] [error] [client 192.168.2.70]   File "/var/data/curtana/curtana.wsgi", line 1
[Fri Nov 19 08:25:08 2010] [error] [client 192.168.2.70]      import sys
[Fri Nov 19 08:25:08 2010] [error] [client 192.168.2.70]           ^
[Fri Nov 19 08:25:08 2010] [error] [client 192.168.2.70]  SyntaxError: invalid syntax

这似乎让我尝试基本的应用程序。

感谢您的任何建议。

编辑添加,这是一个回溯:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb751a700 (LWP 8092)]
0xb6b3a920 in PyParser_AddToken (ps=0x8543f90, type=8, str=0x845a480 ")", 
    lineno=1, col_offset=39, expected_ret=0xbfffe378) at ../Parser/parser.c:274
274     ../Parser/parser.c: No such file or directory.
        in ../Parser/parser.c
(gdb) backtrace
#0  0xb6b3a920 in PyParser_AddToken (ps=0x8543f90, type=8, str=0x845a480 ")", 
    lineno=1, col_offset=39, expected_ret=0xbfffe378) at ../Parser/parser.c:274
#1  0xb6b3ab86 in parsetok (tok=0x8535460, g=<value optimized out>, start=257, 
    err_ret=0xbfffe360, flags=<value optimized out>)
    at ../Parser/parsetok.c:194
#2  0xb6bec5eb in PyParser_SimpleParseFileFlags (fp=0x84f3288, 
    filename=0x85301b0 "/var/www/test/myapp.wsgi", start=257, flags=0)
    at ../Python/pythonrun.c:1404
#3  0xb6c76877 in ?? () from /usr/lib/apache2/modules/mod_wsgi.so
#4  0x084f3288 in ?? ()
#5  0x085301b0 in ?? ()
#6  0x00000101 in ?? ()
#7  0x00000000 in ?? ()

【问题讨论】:

    标签: python apache2 mod-wsgi


    【解决方案1】:

    通读 mod_wsgi 文档,寻找它讨论崩溃的地方。开始:

    http://code.google.com/p/modwsgi/wiki/FrequentlyAskedQuestions http://code.google.com/p/modwsgi/wiki/InstallationIssues

    可能与 mod_python 冲突或由于在运行时发现错误的 Python 安装。

    稍后,请按照以下步骤检查安装:

    http://code.google.com/p/modwsgi/wiki/CheckingYourInstallation


    更新 1

    注释中提到的堆栈跟踪的生成记录在:

    http://code.google.com/p/modwsgi/wiki/DebuggingTechniques

    【讨论】:

    • 感谢 Graham,您的网页有助于消除某些原因。我已经删除了唯一的其他 python 实例和 mod_python,但是你关于使用 gdb 的文本帮助我获得了回溯。现在我做了一个冰雹玛丽并使用'apt-get --reinstall'重新安装了python,现在它正在工作。一定有什么东西破坏了我的安装。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-01
    • 2015-01-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-27
    相关资源
    最近更新 更多