Re: segmentation fault
On Dec 24 2011, 9:07 pm, shlo...@shlomifish.org (Shlomi Fish) wrote: > Hi Motaz, > > On Thu, 22 Dec 2011 10:57:48 -0800 (PST) > > Motaz SAAD wrote: > > Hello, > > > Thanks very much, it is really helpful tool. > > You're welcome. > > > my script spend 10 min running until I get segmentation fault error, > > but when I traced my script and it spend 2 days and still running !!! > > I run tracing using -d flag (perl -d:Trace p.pl) > > is this normal ? > > Well, the "-d:Trace" flag slows down the execution, but it shouldn't be such a > dramatic difference. I guess you've ran into a Heisenbug: > > http://en.wikipedia.org/wiki/Unusual_software_bug#Heisenbug > > I'm not sure what's causing it, but I guess you can try doing manual traces > using prints. > > Regards, > > Shlomi Fish > > -- > - > Shlomi Fish http://www.shlomifish.org/ > Chuck Norris/etc. Facts -http://www.shlomifish.org/humour/bits/facts/ > > And the top story for today: wives live longer than husbands because they are > not married to women. > — Colin Mochrie in Who’s Line is it, Anyway? > > Please reply to list if it's a mailing list post -http://shlom.in/reply. Hello, Thanks for reply, I traced the code with print statements, I also run the script with -d option and the debugger pointed to line while(defined($frPage = $frPages->next)) { which cause the segmentation fault !!! it is very strange that this statement worked thousands of time then cause segmentation fault !. I am afraid it is a problem of memory or it is a bug in cpan Parse::MediaWikiDump package any comments, tips, will be appreciated thanks best regards, Motaz -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: segmentation fault
On Dec 21, 5:37 pm, shlo...@shlomifish.org (Shlomi Fish) wrote: > On Wed, 21 Dec 2011 09:48:19 -0600 > > > > > > > > > > Robert Wohlfarth wrote: > > On Tue, Dec 20, 2011 at 11:25 AM, Motaz SAAD wrote: > > > > I am a beginner in perl and I have segmentation fault in my code. the > > > code run perfectly for the until the third iteration and it produce > > > segmentation fault in the inner while loop in the 3rd iteration of > > > the outer while loop. > > > Would you please help me with hints. > > > Your help will be appreciated > > > If it were me, I would add "print" statements inside of the loop (see > > below). When it segfaults, you see which two "print"s the error comes > > between. Then move those closer and closer until you find the line causing > > the error. That narrows down the scope. It looks like you started down > > that path already... > > You can achieve the same effect much more easily and without polluting your > code using Devel::Trace : > > *http://search.cpan.org/dist/Devel-Trace/ > > There's alsohttp://search.cpan.org/dist/Devel-Trace-More/and my > ownhttp://search.cpan.org/dist/Devel-LineTrace/(which does something a > bit different than the others) which may prove of use. > > Regards, > > Shlomi Fish > > -- > - > Shlomi Fish http://www.shlomifish.org/ > "Star Trek: We, the Living Dead" -http://shlom.in/st-wtld > > No one calls Xena the warrior princess “Zeena” to her face and survives. > Luckily for you, she hasn’t visited the modern day United States yet. > > Please reply to list if it's a mailing list post -http://shlom.in/reply. Hello, Thanks very much, it is really helpful tool. my script spend 10 min running until I get segmentation fault error, but when I traced my script and it spend 2 days and still running !!! I run tracing using -d flag (perl -d:Trace p.pl) is this normal ? Thanks, Best Regards, -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
segmentation fault
Hello, I am a beginner in perl and I have segmentation fault in my code. the code run perfectly for the until the third iteration and it produce segmentation fault in the inner while loop in the 3rd iteration of the outer while loop. Would you please help me with hints. Your help will be appreciated -- Motaz SAAD #!/usr/bin/perl -w # Code : Dake use strict; use Parse::MediaWikiDump; use utf8; use XML::Parser; use XML::Writer; use IO::File; binmode STDOUT, ":utf8"; #my $file = shift(@ARGV) or die "must specify a Mediawiki dump file"; my $enWiki = 'enwiki-latest-pages-articles.xml'; my $frWiki = 'frwiki-2023-pages-articles.xml'; my $arWiki = 'arwiki-2018-pages-articles.xml'; my $enPages = Parse::MediaWikiDump::Pages->new($enWiki); my $frPages = Parse::MediaWikiDump::Pages->new($frWiki); my $arPages = Parse::MediaWikiDump::Pages->new($arWiki); my $output = new IO::File("enfrar.xml", ">:utf8"); my $writer = new XML::Writer(OUTPUT => $output, DATA_MODE => 1,DATA_INDENT => 2); $writer->xmlDecl("UTF-8"); my $enPage; #my $frPage; #my $arPage; my $enId; #my $frId; #my $arId; my $enTitle; #my $arTitle; #my $frTitle; my $enText; #my $frText; #my $arText; my $EnCount = 0; my $EnArFrCount = 0; my $EnArCount = 0; my $EnFrCount = 0; my $testCount = 1; #my $category; $writer->startTag("en-fr-ar-wiki"); while(defined($enPage = $enPages->next)) {#for each english article #main namespace only next unless $enPage->namespace eq ''; $enId = $enPage->id; $enTitle = $enPage->title; #$category = $page->category; $enText = $enPage->text; $EnCount++; if($enTitle eq "A") {next;} #if (($$text =~ /\[\[en:/i) && ($$text =~ /\[\[ar:/i)) if ( ($$enText =~ m/\[\[fr:/i) && ($$enText =~ m/\[\[ar:/i) ) {# if the english article contains links for arabic and french articles print "\nlinks found for ar & fr in en article entitled: ", $enTitle , "\n"; my $frPage; my $arPage; my $frId = "id not found"; my $arId = "id not found"; my $arTitle; my $frTitle; my $frText; my $arText; $frText = "text not found"; $arText = "text not found"; $EnArFrCount++; $$enText =~ /\[\[fr:(.*?)\]/ ; $frTitle = $1; $$enText =~ /\[\[ar:(.*?)\]/ ; $arTitle = $1; #enforce the MediaWiki case rules #$frTitle = case_fixer($frTitle); print "searching for fr text in fr wiki\n"; while(defined($frPage = $frPages->next)) {#find the the french article id and text,,, search by article's title #main namespace only next unless $frPage->namespace eq ''; if ($frPage->title eq $frTitle) { my $frTextRef = $frPage->text; $frText = $$frTextRef; $frId = $frPage->id; print "fr text found\n"; last; } }#end while for extracting french article id and text #enforce the MediaWiki case rules #$arTitle = case_fixer($arTitle); print "searching for ar text in ar wiki\n"; while(defined($arPage = $arPages->next)) {#find the the arabic article id and text,,, search by article's title #main namespace only next unless $arPage->namespace eq ''; if ($arPage->title eq $arTitle) { my $arTextRef = $arPage->text; $arText = $$arTextRef; $arId = $arPage->id; print "ar text found\n"; last; } }#end while for extracting arabic article id and text print $enId; print ","; print $enTitle; print ","; print $frTitle; print ","; print $arTitle; print"\n"; #SQL $writer->startTag("page"); $writer->startTag("en");