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

p5pRT opened this issue Sep 12, 1999 · 6 comments

segment fault #511

p5pRT opened this issue Sep 12, 1999 · 6 comments


Copy link

@p5pRT p5pRT commented Sep 12, 1999

Migrated from (status was 'rejected')

Searchable as RT1357$

Copy link
Collaborator Author

@p5pRT p5pRT commented Sep 12, 1999


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";
  <TD><FONT SIZE=3 FACE=Helvetica,Arial>
  <TD><FONT SIZE=3 FACE=Helvetica,Arial>
  <A HREF="$loc">$sub</A>
  <TD><FONT SIZE=3 FACE=Helvetica,Arial>
  <A HREF="\"$mfrm\"">$frm</A>

my $header = << 'EOF';
<BODY BGCOLOR=0 TEXT=6fafff LINK=afdfff VLINK=ffbfff>
  <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>
  <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>

my $trailer = << '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";
  close FH;
  print IFH &plink_index("$ldir/$fn", $dat, $frm, $sub);
print "Done.\n";

print IFH $trailer;
close IFH;


Use this by​:
$ mkdir output
$ ./ /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.

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:
    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
    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:

Environment for perl 5.00503:
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PERL_BADLANG (unset)

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

Copy link
Collaborator Author

@p5pRT p5pRT commented Apr 27, 2003

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

Copy link
Collaborator Author

@p5pRT p5pRT commented Dec 8, 2008

From @chorny


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​://

Copy link
Collaborator Author

@p5pRT p5pRT commented Dec 8, 2008

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

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
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.