Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

perl ithread issue

by elf_firein (Acolyte)
on Jan 05, 2009 at 13:53 UTC ( [id://734169]=perlquestion: print w/replies, xml ) Need Help??

elf_firein has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I am new in perl programming. I have used perl5.8.8 on solaris 8 with threaded options. I have written an application which has forked a child. And child is spawning several perl-threads. Each thread is doing following task independently:

1. creating a file & writing some data in proper manner. Every variable thats need to be get modified, I have used with my directive in thread function. The rest of the vaiable thats are read-only in child threads kept as thread::shared

2. then each thread forking a C++ application which is in turn parsing the perepared file & forming packet & firing packet through socket & receiving response from remote server. All modifiable variables are kept local as mentioned before & read-only vaiables are kept shared.

3. the output of this C++ apllication is analysed in my perl application & it is updating the database. I have used DBI module to intereact with database. In-order to maintain thread-safe manner( as DBI is not safe) I have made local to thread function wataever DBI object I am creating.

i am joing all threads to the child process.When all threads completes its work it is exting using thr->exit().When all threads are exiting child process is exiting automatically. I am stoping the parent process(my application which is forking child process) to stop forking one more child until previous child is exited properly using some unix command( combination of ps -ef & grep).

This application is working fine with 10000 data but when we are increasing the data it is throwing core dump. I have analized core dump with the help of gdb. I have got following stack trace:

/opt/radius/sql/scripts/DMCoA>gdb /opt/radius/perl588/bin/perl ./core GNU gdb 6.0 Copyright 2003 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and y +ou are welcome to change it and/or distribute copies of it under certain cond +itions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for det +ails. This GDB was configured as "sparc-sun-solaris2.8"... warning: core file may not match specified executable file. Core was generated by `/opt/radius/perl588/bin/perl /opt/radius/sql/sc +ripts/DMCo A/Monitor.pl 1'. Program terminated with signal 11, Segmentation fault. Reading symbols from /usr/lib/libsocket.so.1...done. Loaded symbols for /usr/lib/libsocket.so.1 Reading symbols from /usr/lib/libnsl.so.1...done. Loaded symbols for /usr/lib/libnsl.so.1 Reading symbols from /usr/lib/libdl.so.1...done. Loaded symbols for /usr/lib/libdl.so.1 Reading symbols from /usr/lib/libm.so.1...done. Loaded symbols for /usr/lib/libm.so.1 Reading symbols from /usr/lib/libpthread.so.1...done. Loaded symbols for /usr/lib/libpthread.so.1 Reading symbols from /usr/lib/libc.so.1...done. Loaded symbols for /usr/lib/libc.so.1 Reading symbols from /usr/lib/libmp.so.2...done. Loaded symbols for /usr/lib/libmp.so.2 Reading symbols from /usr/platform/SUNW,Ultra-250/lib/libc_psr.so.1... +done. Loaded symbols for /usr/platform/SUNW,Ultra-250/lib/libc_psr.so.1 Reading symbols from /usr/lib/libthread.so.1...done. Loaded symbols for /usr/lib/libthread.so.1 Reading symbols from /usr/lib/locale/en_GB.ISO8859-1/en_GB.ISO8859-1.s +o.2... done. Loaded symbols for /usr/lib/locale/en_GB.ISO8859-1/en_GB.ISO8859-1.so. +2 Reading symbols from /opt/radius/perl588/lib/perl5/site_perl/5.8.8/sun +4-solaris- thread-multi/auto/DBI/DBI.so...done. Loaded symbols for /opt/radius/perl588/lib/perl5/site_perl/5.8.8/sun4- +solaris-th read-multi/auto/DBI/DBI.so ---Type <return> to continue, or q <return> to quit--- Reading symbols from /opt/radius/perl588/lib/perl5/5.8.8/sun4-solaris- +thread-mul ti/auto/POSIX/POSIX.so...done. Loaded symbols for /opt/radius/perl588/lib/perl5/5.8.8/sun4-solaris-th +read-multi /auto/POSIX/POSIX.so Reading symbols from /opt/radius/perl588/lib/perl5/5.8.8/sun4-solaris- +thread-mul ti/auto/IO/IO.so...done. Loaded symbols for /opt/radius/perl588/lib/perl5/5.8.8/sun4-solaris-th +read-multi /auto/IO/IO.so Reading symbols from /opt/radius/perl588/lib/perl5/5.8.8/sun4-solaris- +thread-mul ti/auto/Fcntl/Fcntl.so...done. Loaded symbols for /opt/radius/perl588/lib/perl5/5.8.8/sun4-solaris-th +read-multi /auto/Fcntl/Fcntl.so Reading symbols from /opt/radius/perl588/lib/perl5/5.8.8/sun4-solaris- +thread-mul ti/auto/threads/threads.so...done. Loaded symbols for /opt/radius/perl588/lib/perl5/5.8.8/sun4-solaris-th +read-multi /auto/threads/threads.so Reading symbols from /opt/radius/perl588/lib/perl5/5.8.8/sun4-solaris- +thread-mul ti/auto/threads/shared/shared.so...done. Loaded symbols for /opt/radius/perl588/lib/perl5/5.8.8/sun4-solaris-th +read-multi /auto/threads/shared/shared.so Reading symbols from /opt/radius/perl588/lib/perl5/5.8.8/sun4-solaris- +thread-mul ti/auto/Filter/Util/Call/Call.so...done. Loaded symbols for /opt/radius/perl588/lib/perl5/5.8.8/sun4-solaris-th +read-multi /auto/Filter/Util/Call/Call.so Reading symbols from /opt/radius/perl588/lib/perl5/site_perl/5.8.8/sun +4-solaris- thread-multi/auto/DBD/Oracle/Oracle.so...done. Loaded symbols for /opt/radius/perl588/lib/perl5/site_perl/5.8.8/sun4- +solaris-th read-multi/auto/DBD/Oracle/Oracle.so Reading symbols from /raid1/oracle9b/lib/libclntsh.so.9.0...done. Loaded symbols for /raid1/oracle9b/lib/libclntsh.so.9.0 Reading symbols from /usr/lib/libgen.so.1...done. Loaded symbols for /usr/lib/libgen.so.1 Reading symbols from /usr/lib/libsched.so.1...done. Loaded symbols for /usr/lib/libsched.so.1 Reading symbols from /usr/lib/libaio.so.1...done. Loaded symbols for /usr/lib/libaio.so.1 Reading symbols from /usr/lib/librt.so.1...done. Loaded symbols for /usr/lib/librt.so.1 Reading symbols from /usr/lib/libkstat.so.1...done. Loaded symbols for /usr/lib/libkstat.so.1 Reading symbols from /raid1/oracle9b/lib/libwtc9.so...done. Loaded symbols for /raid1/oracle9b/lib/libwtc9.so #0 0x0007a944 in S_raise_signal () (gdb) bt full #0 0x0007a944 in S_raise_signal () No symbol table info available. #1 0x0007a994 in Perl_csighandler () No symbol table info available. #2 0xff0db220 in __sighndlr () from /usr/lib/libthread.so.1 No symbol table info available. #3 <signal handler called> No symbol table info available.

I am looking for suggestion from monks to identify the problem behind it.

With Regards,

Kaustuv

Replies are listed 'Best First'.
Re: perl ithread issue
by ww (Archbishop) on Jan 05, 2009 at 14:07 UTC
      Hi ww, Other monk has formated the post now. Can you please go through it. I shall give you more details if you need clarification to resolve the issue.waiting for your reply.
Re: perl ithread issue
by tilly (Archbishop) on Jan 06, 2009 at 02:58 UTC
    Let me paraphrase. "I am new to perl programming, but I'm combining a whole lot of complex things that I'm not going to show you in a way that is likely to go boom and it went boom. Here is the core dump. Can you please debug my problem?"

    Uh...

    There are just too many reasonable possibilities to look at. Looking at the dump it looks like a thread got a signal and dumped core instead of handling it properly. At a really wild guess it has to do with the bug fixed by patch 33741. (If I am right, then I should go and buy a lottery ticket.)

      Hi, This patch is available in perl 5.10.0 also. I have tried with perl5.10. But still it is throwing core dump. this time there is no helping message when using gdb core. Except that what are the posssibility you can suggest? With regards, Kaustuv
Re: perl ithread issue
by BrowserUk (Patriarch) on Jan 06, 2009 at 18:00 UTC

    You are really asking for the impossible. Hoping that someone will be able to debug your code on the basis of a few hundred lines of debugger output.

    Reading the sparse details of what you are doing (which is drowned in that sea of mostly useless debugger output), is this a fair summary of your application?

    You have an application (Perl?) that forks a child process (Perl?) that:

    • Spawns several ithreads each of which:
      1. Write a file
      2. Forks a C++ application that reads and processes that file and writes (pipes) data
      3. Processes the output from the C++ app and uses DBI to talk to a DB.

    Assuming that's correct, a couple of comments.

    1. Very few people (maybe 3 or 4 in the last 7+years), have come here describing code that combined both forking and threading in the same application.

      And of those 3 or 4, none have ever come back and described having successfully solved whatever problem they originally came here with.

      That doesn't mean they never did solve it, far too many posts here never get a "i finally solved it this way" summation, but it does tend to indicate that you are moving in what is fairly uncharted waters.

      That said, if the initial fork is done prior to any threads being spawned, and any subsequent re-fork of the parent is waiting until the initial child fork is complete, there's probably no great dangers with that.

      But note, that is just speculation, as I don't use any systems that support a true fork.

    2. Using DBI in multiple threads is historically, (and to the best of my knowledge still generally) considered a no-no.

      You describe: "In-order to maintain thread-safe manner( as DBI is not safe) I have made local to thread function whatever DBI object I am creating."

      Again, historically, this is not enough. Although logic implies that using different DBI instances from different threads should be "thread-safe"--and probably is at the Perl level--the real problems with thread-safety often lie in the vendor supplied C-libraries and XS wrappers around them. If they are not thread-safe internally, then there is little you, or the perl authors can do about it at the perl level.

      That does not mean that on your particular platform and DB vendor, that DBI isn't thread-safe, but it does mean that you should attempt to find out whether it is? And should perhaps assume it isn't until you get positive confirmation to the contrary.

    None of this is very helpful, but it may give you cause for pause in assuming that what you are doing is inherently flawed or not. You might also try asking on DBI/Oracle news groups for further information.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://734169]
Approved by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2024-04-23 17:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found