Home: Perl Programming Help: Intermediate:
fork, $SIG{CHLD}, segfault help



zatlas1
User

May 23, 2018, 2:34 PM


Views: 4509
fork, $SIG{CHLD}, segfault help

Hi All
My client has rather an old environment, very old, but it is not in my hands. We are moving a Perl script from Perl 5.6.1 on Solaris 8 to Perl 5.10.0 on Solaris 10. The script which works correctly on the old environment, gets http requests, spawn children to handle them using fork() and use $SIG{CHLD} = \&waitme; to handle the children and their various possible exit codes. All these components are written in rather simple style that adhere with the common recommended way in the documentation.

The program use a home growen module:
use XXX::YYY;
it is the same module in both environments. When this use statement is commented out, the program works flawlessly in the new environment, providing I do not use any function of that module. However, as soon as I un-comment the use statement and repeat the simple tests, I get 'segmentation fault' after the child exits and the parent (or the waitme routine) try to wrap up.

I need some guidance on what to look at and/or how to set my tests, so I can find what the heck does this module violate!!! This is not so much a coding question as much as it is a request for advice, what should I focus on, and how do I approach this.

Thank you all


BillKSmith
Veteran

May 23, 2018, 9:08 PM


Views: 4501
Re: [zatlas1] fork, $SIG{CHLD}, segfault help

We need to know more about the module. Is the module written in pure perl or does it use the C extension? How did you install it on the new system? Do you have a test suite for it? Did it pass all the tests when you installed it? Does the module itself use modules which may not be installed or may have version issues?
Good Luck,
Bill


zatlas1
User

May 24, 2018, 6:19 AM


Views: 4492
Re: [BillKSmith] fork, $SIG{CHLD}, segfault help

1. Is the module written in pure perl or does it use the C extension?
A. It is written in pure Perl, however, it is in charge of connecting to various databases, so it does call all these drivers.

2. How did you install it on the new system?
A. I do not know. It works in the new system for few years already, flawlessly. I am moving the last few remnants of the old system.

3. Do you have a test suite for it?
A. No.

4. Did it pass all the tests when you installed it?
A. See above, it works flawlessly.

5. Does the module itself use modules which may not be installed or may have version issues?
A. See above. There is no version issue.

Again, there is an issue, but I do not know how to go about testing it.
The problem seem to me to be related to the clean up of a child thread in multi-threaded program. We do not have any other multi-threaded program in the new system.
Thanks
ZA


zatlas1
User

May 24, 2018, 8:47 AM


Views: 4488
Re: [zatlas1] fork, $SIG{CHLD}, segfault help

Some news about this subject

The actual library that causes the issue is Sybase::CTlib which is obviously not a homegrown library.

Again, it is working fine in Perl 5.6.1

ZA


FishMonger
Veteran / Moderator

May 24, 2018, 9:48 AM


Views: 4487
Re: [zatlas1] fork, $SIG{CHLD}, segfault help

Did you simply copy the module file to the new server?

The module needs to be built/compiled on the new server.


zatlas1
User

May 25, 2018, 6:07 AM


Views: 4471
Re: [FishMonger] fork, $SIG{CHLD}, segfault help

Since I was not the one who had installed it, I followed this advice, downloaded what seems to be the latest CTlib (2.19) and installed it:

perl Makefile.PL PREFIX=/home/myuser/opt/perl/lib/site_perl/5.10.0/sun4-solaris-thread-multi/Sybase

There was no significant warning except of a few:
"Unknown Client Library version - assuming FreeTDS."

So I did:

make test

But this time I got:

cp lib/ctutil.pl blib/lib/ctutil.pl
cp lib/sql.pl blib/lib/sql.pl
cp lib/sybutil.pl blib/lib/sybutil.pl
cp lib/sybperl.pl blib/lib/sybperl.pl
cp BCP.pm ../blib/lib/Sybase/BCP.pm
Manifying ../blib/man3/Sybase::BCP.3
cp BLK.pm ../blib/lib/Sybase/BLK.pm
Manifying ../blib/man3/Sybase::BLK.3
cp CTlib.pm ../blib/lib/Sybase/CTlib.pm
AutoSplitting ../blib/lib/Sybase/CTlib.pm (../blib/lib/auto/Sybase/CTlib)
/usr/local/bin/perl /opt/perl/lib/5.10.0/ExtUtils/xsubpp -prototypes -typemap /opt/perl/lib/5.10.0/ExtUtils/typemap CTlib.xs > CTlib.xsc && mv CTlib.xsc CTlib.c
cc -c -I/opt/sybase/default/OCS/include -D_REENTRANT -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DPERL_USE_SAFE_PUTENV -DPERL_USE_SAFE_PUTENV -O -DVERSION=\"2.19\" -DXS_VERSION=\"2.19\" -KPIC "-I/opt/perl/lib/5.10.0/sun4-solaris-thread-multi/CORE" -DCTLIBVS=100 -DSYBPLVER='"2.19"' -DDO_TIE CTlib.c
/usr/ucb/cc: language optional software package not installed
*** Error code 1
make: Fatal error: Command failed for target `CTlib.o'
Current working directory /home/myuser/sybperl-2.19/CTlib
*** Error code 1
The following command caused the error:
cd CTlib && make -f Makefile all LIBPERL_A="libperl.a" LINKTYPE="dynamic" OPTIMIZE="-O" PREFIX="/home/myuser/opt/perl/lib/site_perl/5.10.0/sun4-solaris-thread-multi/Sybase"
make: Fatal error: Command failed for target `subdirs'

Could somebody explain the issue please?
Thank you
ZA


zatlas1
User

May 25, 2018, 9:13 AM


Views: 4462
Re: [zatlas1] fork, $SIG{CHLD}, segfault help

I went farther:
cd CTlib

make -f Makefile all LIBPERL_A="libperl.a" LINKTYPE="dynamic" OPTIMIZE="-O" PREFIX="/home/myuser/opt/perl/lib/site_perl/5.10.0/sun4-solaris-thread-multi/Sybase"

and got:

cc -c -I/opt/sybase/default/OCS/include -D_REENTRANT -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DPERL_USE_SAFE_PUTENV -DPERL_USE_SAFE_PUTENV -O -DVERSION=\"2.19\" -DXS_VERSION=\"2.19\" -KPIC "-I/opt/perl/lib/5.10.0/sun4-solaris-thread-multi/CORE" -DCTLIBVS=100 -DSYBPLVER='"2.19"' -DDO_TIE CTlib.c
/usr/ucb/cc: language optional software package not installed
*** Error code 1
make: Fatal error: Command failed for target `CTlib.o'


So cc is not installed... will report farther


zatlas1
User

Jun 14, 2018, 10:47 AM


Views: 4196
Re: [zatlas1] fork, $SIG{CHLD}, segfault help

CTlib does not work correctly in forked environment and we really did not need it.
Thank you all