Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

segment fault #511

Closed
p5pRT opened this issue Sep 12, 1999 · 6 comments
Closed

segment fault #511

p5pRT opened this issue Sep 12, 1999 · 6 comments

Comments

@p5pRT
Copy link
Collaborator

@p5pRT p5pRT commented Sep 12, 1999

Migrated from rt.perl.org#1357 (status was 'rejected')

Searchable as RT1357$

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Sep 12, 1999

From brain@7a69.2y.net

I am working on a program which takes a unix mbox file and turns it into "purty"
html for a small mailing list I run w/ friends. I am using debian Linux
unstable. It is a linux 2.2.12/glibc2.1 system, I didn't compile perl though it
came from a deb package. I installed Mail​::Folder with CPAN in the canonical
way. This seems to segfault on any mbox not just the 2meg one I am parsing.

The problem started occuring after I added the if($#tfrm > 0) statement in
sub plink_index().

Below is the script/program​:

#!/usr/bin/perl -w
# This is a perl script to parse out a mailbox file and put it in
# a directory.
# Ben Cooper. fall 1999

use Mail​::Folder​::Mbox;
use integer;

####### html stuffs

###### index.html file
# link (to, description)
sub plink_index {
  my ($loc, $dat, $frm, $sub) = @​_;

  my @​tfrm = split(' ', $frm);
  my $mfrm = $tfrm[$#tfrm];
  $mfrm =~ s/^<(.*?)>$/$1/;
  if($#tfrm > 0) {
  $frm = join(' ', $tfrm[0..($#tfrm-1)]);
  } else {
  $frm = $mfrm;
  }
  $mfrm = 'mailto​:' . $frm;

  my $ret = << "EOF";
<TR VALIGN=TOP ALIGN=LEFT>
  <TD><FONT SIZE=3 FACE=Helvetica,Arial>
  $dat
  </FONT>
  <TD><FONT SIZE=3 FACE=Helvetica,Arial>
  <A HREF="$loc">$sub</A>
  </FONT>
  <TD><FONT SIZE=3 FACE=Helvetica,Arial>
  <A HREF="\"$mfrm\"">$frm</A>
  </FONT>
EOF
}

my $header = << 'EOF';
<HTML>
<BODY BGCOLOR=0 TEXT=6fafff LINK=afdfff VLINK=ffbfff>
  <TABLE WIDTH=100% BORDER=0 FRAME=VOID CELLPADDING=2 CELLSPACING=2>
  <TR VALIGN=TOP ALIGN=CENTER>
  <TH COLSPAN=3>
  <FONT FACE=Arial,Helvetica SIZE=5 COLOR=ffffff>The Blunt List Archives</B></FONT><BR>
  <FONT FACE=Arial,Helvetica SIZE=4 COLOR=ffffff>Ben Cooper fall 1999.</FONT>
  <BR><BR>
  <TR VALIGN=TOP ALIGN=LEFT>
  <TH WIDTH=*1><FONT SIZE=3 FACE=Helvetica,Arial color=bfbfbf><B>Date</B></FONT>
  <TH WIDTH=*3><FONT SIZE=3 FACE=Helvetica,Arial color=bfbfbf><B>Subject</B></FONT>
  <TH WIDTH=*1><FONT SIZE=3 FACE=Helvetica,Arial color=bfbfbf><B>From</B></FONT>
EOF

my $trailer = << 'EOF';
</TABLE>
</BODY>
</HTML>
EOF

####### main......
my $dir_sep = 3; # num of levels to storage

die "Usage parse​: mboxfile outputdirectory\n" unless @​ARGV > 1;
my ($fname, $odir) = (shift @​ARGV, shift @​ARGV);

my $mf = Mail​::Folder​::Mbox->new('AUTODETECT', $fname);
$mf->open($fname) or die "Cannot open mailbox $fname\n";
open IFH, ">$odir/index.html" or die "Cannot open index file\n";
print IFH $header;

print $mf->qty(), " items in archive\n";
for my $mnum (sort { $b <=> $a } $mf->message_list()) {
  my $mi = $mf->get_message($mnum);
  my $mh = $mi->head();

  my $sub = $mh->get('Subject');
  chomp $sub;
  my $frm = $mh->get('From');
  chomp $frm;
  my $dat = $mh->get('Date');
  chomp $dat;
  my @​dat = split(' ', $dat);
  $dat = join(' ', @​dat[1..4]);

  my $sdir = $odir;
  my $ldir;
  my $ldir_first = 1;
  for my $dir (reverse @​dat[$dir_sep..3]) {
  $sdir .= ('/' . $dir);
  if($ldir_first) {
  $ldir = $dir;
  $ldir_first = 0;
  }
  else {
  $ldir .= ('/' . $dir);
  }
  mkdir $sdir, 0755;
  }

  my $fn = $dat . '.' . $frm;
  $fn =~ s/\s//g;
  $fn =~ s|/||g;
  $fn =~ s/"//g;
  open FH, ">$sdir/$fn" or die "Cannot open file​: $sdir/$fn\n";
  $mi->print(\*FH);
  close FH;
  print IFH &plink_index("$ldir/$fn", $dat, $frm, $sub);
}
print "Done.\n";

print IFH $trailer;
close IFH;

__END__

Use this by​:
$ mkdir output
$ ./parse.pl /path/to/mbox output

Inside output there should be a file index.html. Which contains links
to all the messages, which should be in a dir hiarchy based on the date
of the message.

I have stashed away a copy of this script incase you have any future questions.

Ben Cooper.
neb@​one.net

Perl Info


Site configuration information for perl 5.00503:

Configured by darren at Thu Aug 19 01:13:41 PDT 1999.

Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration:
  Platform:
    osname=linux, osvers=2.0.36, archname=i386-linux
    uname='linux broca 2.0.36 #2 sun nov 29 02:38:59 pst 1998 i686 unknown '
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef useperlio=undef d_sfio=undef
  Compiler:
    cc='cc', optimize='-O2', gccversion=2.95.1 19990809 (prerelease)
    cppflags='-Dbool=char -DHAS_BOOL -D_REENTRANT -DDEBIAN -I/usr/local/include'
    ccflags ='-Dbool=char -DHAS_BOOL -D_REENTRANT -DDEBIAN -I/usr/local/include'
    stdchar='char', d_stdstdio=undef, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lndbm -lgdbm -ldbm -ldb -ldl -lm -lc -lposix -lcrypt
    libc=, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:
    


@INC for perl 5.00503:
    /usr/lib/perl5/5.005/i386-linux
    /usr/lib/perl5/5.005
    /usr/local/lib/site_perl/i386-linux
    /usr/local/lib/site_perl
    /usr/lib/perl5
    .


Environment for perl 5.00503:
    HOME=/home/brain
    LANG=C
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/X11R6/bin:/home/brain/bin:/usr/local/jdk/bin:/home/brain/bin:.
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Apr 27, 2003

From @ask

Please make a smaller test case and retest it with 5.8.0.

Thanks for looking into this!

- ask

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Apr 27, 2003

@ask - Status changed from 'open' to 'stalled'

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Dec 8, 2008

From @chorny

http​://rt.perl.org/rt3/Ticket/Display.html?id=1357

Mail​::Folder​::Mbox module is very old (last release in 1998), it depends
on XS module File​::Sync and it has 'PASS (3) FAIL (116)' reports by
cpantesters. I also was not able to install it.

This bug is also very old (1999), reporter never answered. Perl was
seriously changed in this period. IMHO this bug can be closed.

--
Alexandr Ciornii, http​://chorny.net

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Dec 8, 2008

The RT System itself - Status changed from 'stalled' to 'open'

@p5pRT
Copy link
Collaborator Author

@p5pRT p5pRT commented Dec 8, 2008

@smpeters - Status changed from 'open' to 'rejected'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.