Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Segmentation Fault

by abhay180 (Acolyte)
on Aug 28, 2009 at 05:49 UTC ( #791836=perlquestion: print w/ replies, xml ) Need Help??
abhay180 has asked for the wisdom of the Perl Monks concerning the following question:

I use the following piece of Code to read in a 10,000 entry file and sort the entries in the file in the ascending order. It was working fine for 1000-entries. For 10,000 it exits with a "Segmentation Fault". Any limitations here?
tie @log_array, 'Tie::File', $fname, mode => O_RDWR | O_CREAT; @log_array = sort {$a<=>$b} @log_array;

Comment on Segmentation Fault
Download Code
Re: Segmentation Fault
by stevieb (Chaplain) on Aug 28, 2009 at 06:26 UTC

    what happens if you halve it to 5,000

    ...when that breaks, what happens when you halve the half that you just halved? :)

    iow, either way, you are hitting a bug in the data. Half'ing the problem may help.

    If you find the problem goes away with all of the same data but in segments, use the function to read in the same amount of different data, and try to run the hardware out of memory to find out if exhaustion is the problem.

    Steve

      Thanks for the suggestion. That will take some time for me. Meanwhile is there any other way i can read a file as an array and work on it...just like Tie::File?
      Okie. I figured out the exact failure point. It fails when the file contains greater than or equal to 1021 items. It works at 1020. I tried it with multiple sets of data and everytime i see the same result. Seems some weird limit. How can we address this?
Re: Segmentation Fault
by ikegami (Pope) on Aug 31, 2009 at 19:13 UTC

    That would indicate a bug in XS code, in perl or in the OS.

    Tie::File is a Pure Perl module, so it's not the source of the bug. A bug in perl is the next likely suspect.

    Do you have the same problem with Perl 5.10.1?

      I am using perl version 5.8.8 on an x86_64 Linux m/c. Not sure if i'll be able to try it on 5.10.1.
        You could try 5.8.9 too. Or rebuilding 5.8.8 with a different compiler or different optimisation settings.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (11)
As of 2014-12-22 15:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (119 votes), past polls