Mod_wsgi工作进程分段错误(11)

发布于 2024-11-09 02:54:26 字数 3743 浏览 0 评论 0原文

我的 django 应用程序有问题,该应用程序由 apache/mod_wsgi 托管。我在应用程序中添加了一些 matplotlib 代码,apache 工作进程现在崩溃了。

我将此问题简化为以下内容:

  • 没有任何 matplotlib 导入,
  • 当在应用程序中的任何位置添加“import matplotlib”时,应用程序工作正常,工作进程因段错误而死亡,并且用户看不到来自服务器的回复
  • “import matplotlib”在命令行 python 解释器中工作得很好- 段错误仅发生在 apache 进程中

这是日志条目:

[Tue May 24 08:29:08 2011] [notice] child pid 17576 exit signal Segmentation fault (11)

我无法在其他计算机上重现问题。 我尝试删除 (rm site-packages/matplotli*) 并安装不同版本的 matplotlib (0.99.3、1.0.0、1.0.1) 我尝试在 virtualenv 中安装所有模块,并从 .wsgi 脚本指向 virtualenv。

我试过这个: 错误:子进程 pid 6695 退出信号分段错误 (11) 我阅读了http://code.google.com/p/modwsgi/wiki/ 也是如此。

任何有关如何调试/解决此问题的指示将不胜感激。

(我什至准备移动到任何其他服务器(paste/cherrypy + apache mod_proxy 等)来消除该问题。)

这是我的 apache 设置:

/usr/sbin/httpd -V

Server version: Apache/2.2.15 (Unix)
Server built:   Apr 10 2010 11:21:07
Server's Module Magic Number: 20051115:24
Server loaded:  APR 1.3.9, APR-Util 1.3.10
Compiled using: APR 1.3.9, APR-Util 1.3.9
Architecture:   32-bit
Server MPM:     Prefork
  threaded:     no
    forked:     yes (variable process count)
Server compiled with....
 -D APACHE_MPM_DIR="server/mpm/prefork"
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=128
 -D HTTPD_ROOT="/etc/httpd"
 -D SUEXEC_BIN="/usr/sbin/suexec"
 -D DEFAULT_PIDLOG="logs/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_LOCKFILE="logs/accept.lock"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="conf/mime.types"
 -D SERVER_CONFIG_FILE="conf/httpd.conf"

< /usr/sbin/httpd -l

Compiled in modules:
  core.c
  prefork.c
  http_core.c
  mod_so.c

/usr/sbin/httpd -M

Loaded Modules:
 core_module (static)
 mpm_prefork_module (static)
 http_module (static)
 so_module (static)
 auth_basic_module (shared)
 auth_digest_module (shared)
 authn_file_module (shared)
 authn_alias_module (shared)
 authn_anon_module (shared)
 authn_dbm_module (shared)
 authn_default_module (shared)
 authz_host_module (shared)
 authz_user_module (shared)
 authz_owner_module (shared)
 authz_groupfile_module (shared)
 authz_dbm_module (shared)
 authz_default_module (shared)
 ldap_module (shared)
 authnz_ldap_module (shared)
 include_module (shared)
 log_config_module (shared)
 logio_module (shared)
 env_module (shared)
 ext_filter_module (shared)
 mime_magic_module (shared)
 expires_module (shared)
 deflate_module (shared)
 headers_module (shared)
 usertrack_module (shared)
 setenvif_module (shared)
 mime_module (shared)
 dav_module (shared)
 status_module (shared)
 autoindex_module (shared)
 info_module (shared)
 dav_fs_module (shared)
 vhost_alias_module (shared)
 negotiation_module (shared)
 dir_module (shared)
 actions_module (shared)
 speling_module (shared)
 userdir_module (shared)
 alias_module (shared)
 rewrite_module (shared)
 wsgi_module (shared)
 ssl_module (shared)
Syntax OK

Apache 配置

<VirtualHost *:443>

    ServerName              somesite.com
    DocumentRoot            "/somedir"

    WSGIApplicationGroup %{GLOBAL}
    WSGIScriptAlias / /somedir/production.wsgi

    <..>

</VirtualHost>

I am having a problem with my django application, which is hosted with apache/mod_wsgi. I added some matplotlib code into the application, and apache worker processes now crashing.

I reduced this problem to the following:

  • Without any matplotlib imports application works ok
  • when "import matplotlib" is added anywhere in the application, worker processes die with segfault and users see no reply from server
  • "import matplotlib" works just fine in commandline python interpreter - segfault happens only in apache processes

Here is the log entry:

[Tue May 24 08:29:08 2011] [notice] child pid 17576 exit signal Segmentation fault (11)

I cannot reproduce problem on other computer.
I tried to remove (rm site-packages/matplotli*) and install different versions of matplotlib (0.99.3, 1.0.0, 1.0.1)
I tried to install all modules in virtualenv and point to virtualenv from my .wsgi script.

I tried this:
Error: child pid 6695 exit signal Segmentation fault (11)
I read http://code.google.com/p/modwsgi/wiki/ as well.

Any pointers on how to debug/workaround this issue will be much appreciated.

(I am even ready to move to any other server (paste/cherrypy + apache mod_proxy, etc.) to eliminate the problem.)

Here are my apache settings:

/usr/sbin/httpd -V

Server version: Apache/2.2.15 (Unix)
Server built:   Apr 10 2010 11:21:07
Server's Module Magic Number: 20051115:24
Server loaded:  APR 1.3.9, APR-Util 1.3.10
Compiled using: APR 1.3.9, APR-Util 1.3.9
Architecture:   32-bit
Server MPM:     Prefork
  threaded:     no
    forked:     yes (variable process count)
Server compiled with....
 -D APACHE_MPM_DIR="server/mpm/prefork"
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=128
 -D HTTPD_ROOT="/etc/httpd"
 -D SUEXEC_BIN="/usr/sbin/suexec"
 -D DEFAULT_PIDLOG="logs/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_LOCKFILE="logs/accept.lock"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="conf/mime.types"
 -D SERVER_CONFIG_FILE="conf/httpd.conf"

/usr/sbin/httpd -l

Compiled in modules:
  core.c
  prefork.c
  http_core.c
  mod_so.c

/usr/sbin/httpd -M

Loaded Modules:
 core_module (static)
 mpm_prefork_module (static)
 http_module (static)
 so_module (static)
 auth_basic_module (shared)
 auth_digest_module (shared)
 authn_file_module (shared)
 authn_alias_module (shared)
 authn_anon_module (shared)
 authn_dbm_module (shared)
 authn_default_module (shared)
 authz_host_module (shared)
 authz_user_module (shared)
 authz_owner_module (shared)
 authz_groupfile_module (shared)
 authz_dbm_module (shared)
 authz_default_module (shared)
 ldap_module (shared)
 authnz_ldap_module (shared)
 include_module (shared)
 log_config_module (shared)
 logio_module (shared)
 env_module (shared)
 ext_filter_module (shared)
 mime_magic_module (shared)
 expires_module (shared)
 deflate_module (shared)
 headers_module (shared)
 usertrack_module (shared)
 setenvif_module (shared)
 mime_module (shared)
 dav_module (shared)
 status_module (shared)
 autoindex_module (shared)
 info_module (shared)
 dav_fs_module (shared)
 vhost_alias_module (shared)
 negotiation_module (shared)
 dir_module (shared)
 actions_module (shared)
 speling_module (shared)
 userdir_module (shared)
 alias_module (shared)
 rewrite_module (shared)
 wsgi_module (shared)
 ssl_module (shared)
Syntax OK

Apache config

<VirtualHost *:443>

    ServerName              somesite.com
    DocumentRoot            "/somedir"

    WSGIApplicationGroup %{GLOBAL}
    WSGIScriptAlias / /somedir/production.wsgi

    <..>

</VirtualHost>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

生死何惧 2024-11-16 02:54:26

在您所说的维基中,您应该已经找到:

http://code。 google.com/p/modwsgi/wiki/DebuggingTechniques#Debugging_Crashes_With_GDB

作为旁注,建议您不要使用预分叉/嵌入模式。如果您被迫使用 prefork MPM,请使用 mod_wsgi 守护进程模式。阅读:

http://blog.dscpl .com.au/2009/03/load-spikes-and-excessive-memory-usage.html

了解其中的一些原因。

其他人已经让 matplotlib 与 mod_wsgi 一起工作,所以不能立即明显看出问题是什么。

In the wiki you said you read, you should have found:

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

As a side note, it is recommended you do not use prefork/embedded mode. User mod_wsgi daemon mode if you are forced to use prefork MPM. Read:

http://blog.dscpl.com.au/2009/03/load-spikes-and-excessive-memory-usage.html

for some of the reasons why.

Other people have got matplotlib working with mod_wsgi, so not obvious straight away what the issue is.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文