# Segfault in perl module's r-\>print

**URL:** <https://www.ruby-forum.com/t/segfault-in-perl-modules-r-print/206192>\
**Category:** NGINX\
**Created:** [April 25, 2011, 1:05pm UTC](https://www.ruby-forum.com/t/segfault-in-perl-modules-r-print/206192 "2011-04-25T13:05:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [April 25, 2011, 1:05pm UTC](https://www.ruby-forum.com/t/segfault-in-perl-modules-r-print/206192/1 "2011-04-25T13:05:18Z")

</div>

Using $r-\>print() in nginx1.0’s perl module leads to a segfault. The  
problem appears to be in nginx-land, not perl land.  
I am using the first example listed on  
[http://wiki.nginx.org/EmbeddedPerlModule](http://wiki.nginx.org/EmbeddedPerlModule) - this example works fine if  
the $r-\>print()'s are commented out.

Being unfamiliar with the code, I’ve been unable to find where  
ngx\_pcalloc() is being called from XS\_nginx\_print (in  
modules/perl/nginx.xs),  
this seems like it’d be a fairly simple problem to fix but being  
unfamiliar with the code I’ve been unable to track it down - so far.  
Any assistance would be much appreciated.

backtrace:  
#0 0x00007ff6c3421686 in memset () from /lib/libc.so.6  
#1 0x000000000040f437 in ngx\_pcalloc (pool=0xbc4210, size=80) at  
src/core/ngx\_palloc.c:306  
#2 0x00007ff6c2f63647 in XS\_nginx\_print (my\_perl=0xb39b20, cv=) at nginx.xs:543  
#3 0x00007ff6c3e5ec0f in Perl\_pp\_entersub () from  
/usr/lib/libperl.so.5.10  
#4 0x00007ff6c3e5cf86 in Perl\_runops\_standard () from  
/usr/lib/libperl.so.5.10  
#5 0x00007ff6c3e5a9ed in Perl\_call\_sv () from /usr/lib/libperl.so.5.10  
#6 0x0000000000478548 in ngx\_http\_perl\_call\_handler  
(my\_perl=0xb39b20, r=0xbc3cf0, nginx=0xb5d7f8, sub=0xb5dbb8, args=0x0,  
handler=0xb3cfa0, rv=0x0)  
at src/http/modules/perl/ngx\_http\_perl\_module.c:703  
#7 0x00000000004778a6 in ngx\_http\_perl\_handle\_request (r=0xbc3cf0) at  
src/http/modules/perl/ngx\_http\_perl\_module.c:221

Build details:  
CFLAGS=“-g3” ./configure --prefix=/home/coder/nginx/install/  
–without-http-cache --without-http\_charset\_module  
–without-http\_ssi\_module --without-http\_userid\_module  
–without-http\_auth\_basic\_module --without-http\_autoindex\_module  
–without-http\_geo\_module --without-http\_split\_clients\_module  
–without-http\_proxy\_module --without-http\_fastcgi\_module  
–without-http\_uwsgi\_module --without-http\_scgi\_module  
–without-http\_memcached\_module --without-http\_empty\_gif\_module  
–without-http\_browser\_module --without-http\_upstream\_ip\_hash\_module  
–with-file-aio --with-libatomic --with-http\_dav\_module  
–with-http\_perl\_module

gcc version 4.4.1 (Ubuntu 4.4.1-4ubuntu9)  
perl v5.10.0

---

<div class="post-metadata">

**Author:** ![rob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/838e76/32.png) [@rob](https://www.ruby-forum.com/u/rob)\
**Post date:** [April 25, 2011, 10:56pm UTC](https://www.ruby-forum.com/t/segfault-in-perl-modules-r-print/206192/2 "2011-04-25T22:56:25Z")

</div>

Hello!

On Sun, Apr 24, 2011 at 06:50:07AM -0400, Rob wrote:

> unfamiliar with the code I’ve been unable to track it down - so far.  
> #5 0x00007ff6c3e5a9ed in Perl\_call\_sv () from /usr/lib/libperl.so.5.10  
> –without-http-cache --without-http\_charset\_module  
> gcc version 4.4.1 (Ubuntu 4.4.1-4ubuntu9)  
> perl v5.10.0

Works ok here.

Most likely you have your nginx perl module (nginx.so) and nginx  
itself are out of sync, i.e. compiled with different configure  
options. This way I may reproduce similar segfault.

At least “–without-http-cache” will result in ABI change  
(compared to nginx compiled with cache), so there is no surprise  
it segfaults as a result.

Maxim D.
