Important update: the problem is not related to Apache or mod_perl. The simplest demonstration:
> perl -le 'use PerlIO::via::QuotedPrint; binmode(\*STDERR, ":via(PerlIO::via::QuotedPrint):utf8"); open (ERROR, ">&STDERR");' zsh: segmentation fault perl -le
In fact, binmode is executed by my code and open (ERROR, ">&STDERR"); using Parse :: RecDescent.
The original question:
I have a problem with Spreadsheet :: WriteExcel in mod_perl 2.0.5 Apache dies with a segmentation error, and I found out that it occurs in require Parse::RecDescent as part of the Spreadsheet::WriteExcel .
strace shows that the last things that happen duplicate STDERR:
[pid 31253] dup(2) = 8 [pid 31253] ioctl(8, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fffcf66a328) = -1 ENOTTY (Inappropriate ioctl for device) [pid 31253] lseek(8, 0, SEEK_CUR) = 0 [pid 31253] --- SIGSEGV (Segmentation fault) @ 0 (0) ---
I read the Parse::RecDescent and noticed expressions such as open (ERROR, ">&STDERR");
Ok, after some extra experimentation, I have this minimalistic Plack application for playing segfault:
use strict; use warnings;
(I actually use a binmode layer different from PerlIO::via::QuotedPrint , but the effect is the same)
If I do not execute binmode(\*STDERR, ":via(PerlIO... , apache is not segfault.
Unless I duplicate STDERR , apache is not segfault.
If I do both, it will be segfaults.
As a workaround, I can avoid using binmode on STDERR, but this is not good.
Any suggestions on where and how to fix this?
Thanks.
My environment:
perl -v |grep version This is perl 5, version 14, subversion 2 (v5.14.2) built for x86_64-linux-gnu-thread-multi uname -a Linux thinkpad 3.2.0-32-generic
Update: The same code works well with legacy Ubuntu 8.04 + perl 5.8.8 + mod_perl2 2.0.3
Update 2: FreeBSD 9.1 + perl 5.14 + mod_perl 2.0.8 - segfault repetitions
uname -a FreeBSD liruoko.ru 9.1-RELEASE-p5 FreeBSD 9.1-RELEASE-p5 #7 r253740: Sun Jul 28 16:53:08 MSK 2013 roman@thor.cmc.msu.ru :/usr/obj/usr/src/sys/MINI amd64 pkg info |grep apache apache22-itk-mpm-2.2.25 Version 2.2.x of Apache web server with itk MPM. pkg info |grep mod_perl ap22-mod_perl2-2.0.8,3 Embeds a Perl interpreter in the Apache2 server perl -v |grep version This is perl 5, version 14, subversion 4 (v5.14.4) built for amd64-freebsd