mod_perl 分段错误
您好,
我正在 Oracle64 位(Red Hat 克隆)上运行 apache 2.2.3,但我遇到了一个问题。我有一个程序,它利用 MIME::Lite 通过 sendmail 发送邮件(我很抱歉,不确定我正在运行什么版本的 sendmail 或 mod_perl,尽管我确实相信 sendmail 部分是不相关的,正如您稍后会看到的)
有时,apache 会出现段错误 (11),并深入研究 MIME::Lite 模块,我发现它位于以下行:
open SENDMAIL, "|$sendmailcmd" or Carp::croak "open |$sendmailcmd: $!\n"; (this is in MIME::Lite)
现在,人们会自动怀疑 sendmail,但如果我执行同一行来使用 /bin/ cat(如图所示):
open SENDMAIL, "|/bin/cat"
apache 仍然存在段错误。
我将 strace 附加到 apache 进程并看到以下内容: (当它不崩溃时)
12907 write(2, "SENDMAIL send_by_sendmail 1\n", 28) = 28
12907 write(2, "SENDMAIL /usr/lib/sendmail -t -o"..., 40) = 40
12907 pipe([24, 26]) = 0
12907 pipe([28, 29]) = 0
12907 clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x2b4bcbbd75d0) = 13186
请注意“SENDMAIL sent_by_sendmail”是我的评论。您可以清楚地看到管道打开。当它崩溃时,您将看到以下内容:
10805 write(2, "SENDMAIL send_by_sendmail (for y"..., 40) = 40
10805 --- SIGSEGV (Segmentation fault) @ 0 (0) ---
现在请注意,它从不进行管道传输。我尝试过 GDB,但它并没有真正向我展示任何东西。
最后,我编写了一个简单的程序来运行 mod_perl 和常规 cgi:
print header();
print "test";
open SENDMAIL, "|/bin/cat" or Carp::croak "open |sendmailcmd: $!\n";
print SENDMAIL "foodaddy";
close SENDMAIL;
print "test done <br/>";
在 mod_perl 下它已成功崩溃。
我的分析告诉我,这与尝试打开文件句柄有关,管道函数返回 false 或损坏的文件句柄。
我还将文件描述符限制增加到 2048,没有骰子。
有人对我应该看哪里有什么想法吗?有什么想法吗?
我很感激你的帮助
HI,
I'm running an apache 2.2.3 on an Oracle64-bit (Red Hat clone) and I'm hitting a brick wall with an issue. I have a program which utilizes MIME::Lite to send mail through sendmail (I apologize, not sure what versions of sendmail or mod_perl I'm running, although I do believe the sendmail portion is irrelevant as you'll see in a moment)
On occasion, apache will segfault (11), and digging deep into the MIME::Lite module, I see it is on the following line:
open SENDMAIL, "|$sendmailcmd" or Carp::croak "open |$sendmailcmd: $!\n"; (this is in MIME::Lite)
Now, one would automatically suspect sendmail, but if I did the same line to use /bin/cat (as shown):
open SENDMAIL, "|/bin/cat"
apache still segfaults.
I attached an strace to the apache processes and see the following:
(when it does NOT crash)
12907 write(2, "SENDMAIL send_by_sendmail 1\n", 28) = 28
12907 write(2, "SENDMAIL /usr/lib/sendmail -t -o"..., 40) = 40
12907 pipe([24, 26]) = 0
12907 pipe([28, 29]) = 0
12907 clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x2b4bcbbd75d0) = 13186
Note the "SENDMAIL sent_by_sendmail" are my comments. You can clearly see pipes opening. When it DOES crash, you'll see the following:
10805 write(2, "SENDMAIL send_by_sendmail (for y"..., 40) = 40
10805 --- SIGSEGV (Segmentation fault) @ 0 (0) ---
Now notice it never pipes. I've tried GDB and it hasn't really shown me anything.
Finally, I wrote a simple program to run through mod_perl and regular cgi:
print header();
print "test";
open SENDMAIL, "|/bin/cat" or Carp::croak "open |sendmailcmd: $!\n";
print SENDMAIL "foodaddy";
close SENDMAIL;
print "test done <br/>";
Under mod_perl it has successfully crashed.
My analysis is telling me it has to do with it trying to open a file handle, the piping function returns either false or a corrupt file handle.
I also increased the file descriptor limit to 2048, no dice.
Does anyone have any thoughts as to where I should look? Any thoughts?
I appreciate the help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我刚刚花了很长时间来追踪一个以相同症状开始的问题。我最终发现 Test::More 不能很好地与 mod_perl 配合使用。从我的代码中删除这个模块似乎已经解决了问题(到目前为止!)。我没有更深入地了解这一点,但我怀疑问题实际上出在 Test::Builder 中。
I just spent a long time tracking down a problem that started with identical symptoms. I eventually discovered that Test::More does not play well with mod_perl . Removing this module from my code appears to have solved the problem (so far!). I didn't follow this any deeper, but I suspect that the problem actually lies in Test::Builder.
我可能只治疗了症状,而不是原因。当我在包级别使用全局/包作用域变量时,在 Perl 对象实例中使用时,我碰巧遇到了这个问题,一旦我将它们作为对象属性传递,而不是作为自动默认 Perl 变量作用域,我就停止体验 Perl 分段突然故障。
I managed to treat perhaps only the symptoms, not the cause. I happened to have this issue when used global/package scope variables on the package level, used inside a perl object instance, as soon as I passed them as object properties instead, not as automatic default perl variables scoping, I stopped to experience perl segmentation fault suddenly.