Bug 5100 - perl crashing at spamd's "$opt{'socketpath'}"
Summary: perl crashing at spamd's "$opt{'socketpath'}"
Status: RESOLVED WONTFIX
Alias: None
Product: Spamassassin
Classification: Unclassified
Component: spamc/spamd (show other bugs)
Version: SVN Trunk (Latest Devel Version)
Hardware: Macintosh Mac OS X
: P3 blocker
Target Milestone: Undefined
Assignee: SpamAssassin Developer Mailing List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-09-14 18:31 UTC by openmacnews
Modified: 2006-09-15 09:31 UTC (History)
0 users



Attachment Type Modified Status Actions Submitter/CLA Status

Note You need to log in before you can comment on or make changes to this bug.
Description openmacnews 2006-09-14 18:31:31 UTC
i've built SA-dev (r443195) on OSX 10.4.7, w/ perl 588 built from src.

SA builds w/o error.  spamc works OK, and my confs --lint OK.

on exec of 'spamd --daemonize', however, i reproducibly see perl crashes (crash
report @ bottom, below ...)


after some poking around in 'spamd', i find:
 
@ 608
 
	608:	# Be a well-behaved daemon
	609:	my $server;
	610:	if ( $opt{'socketpath'} ) {
	611:	  my $path = $opt{'socketpath'};
 
 
if:
 
	+++	607: die 'DEBUG DEBUG DEBUG';
 
on exec of:
 
	spamd --daemonize
 
@ console:
 
	Sep 14 10:54:02 server spamd[20624]: DEBUG DEBUG DEBUG at ./spamd line 907.\n
 
if, instead:
 
	+++	612: die 'DEBUG DEBUG DEBUG';
 
on exec of:
 
	spamd --daemonize
 
@ console:
 
	Sep 14 10:58:53 server crashdump[20650]: perl crashed
	Sep 14 10:58:54 server crashdump[20650]: crash report written to:
/Library/Logs/CrashReporter/perl.crash.log


thx,

richard


% cat /Library/Logs/CrashReporter/perl.crash.log
======================================================
**********

Host Name:      server
Date/Time:      2006-09-14 10:58:53.177 -0700
OS Version:     10.4.7 (Build 8J135)
Report Version: 4

Command: perl
Path:    /usr/local/perl5/bin/perl
Parent:  launchd [1]

Version: ??? (???)

PID:    20649
Thread: 0

Exception:  EXC_BAD_ACCESS (0x0001)
Codes:      KERN_PROTECTION_FAILURE (0x0002) at 0x00000000

Thread 0 Crashed:
0   libSystem.B.dylib        	0x90131a80 bcmp + 224
1   com.apple.CoreFoundation 	0x902c580c __CFInitialize + 420
2   dyld                     	0x8fe15660
ImageLoaderMachO::doInitialization(ImageLoader::LinkContext const&) + 672
3   dyld                     	0x8fe0bbe8
ImageLoader::recursiveInitialization(ImageLoader::LinkContext const&) + 212
4   dyld                     	0x8fe0bb78
ImageLoader::recursiveInitialization(ImageLoader::LinkContext const&) + 100
5   dyld                     	0x8fe0bb78
ImageLoader::recursiveInitialization(ImageLoader::LinkContext const&) + 100
6   dyld                     	0x8fe0bb78
ImageLoader::recursiveInitialization(ImageLoader::LinkContext const&) + 100
7   dyld                     	0x8fe0de44
ImageLoader::link(ImageLoader::LinkContext const&, ImageLoader::BindingLaziness,
ImageLoader::InitializerRunning, unsigned) + 468
8   dyld                     	0x8fe03ea4 dyld::link(ImageLoader*,
ImageLoader::BindingLaziness, ImageLoader::InitializerRunning) + 380
9   dyld                     	0x8fe09c4c dlopen + 316
10  libSystem.B.dylib        	0x90031014 dlopen + 96
11  perl                     	0x00002d34 XS_DynaLoader_dl_load_file + 340
12  libperl.dylib            	0x0027c6d4 Perl_pp_entersub + 1764
13  libperl.dylib            	0x00273828 Perl_runops_standard + 88
14  libperl.dylib            	0x002080e8 Perl_call_sv + 1416
15  libperl.dylib            	0x0020857c Perl_call_list + 476
16  libperl.dylib            	0x00240a70 Perl_newATTRSUB + 4400
17  libperl.dylib            	0x002413e4 Perl_utilize + 1748
18  libperl.dylib            	0x0022e7dc Perl_yyparse + 4332
19  libperl.dylib            	0x002b24ec S_doeval + 620
20  libperl.dylib            	0x002baabc Perl_pp_require + 4876
21  libperl.dylib            	0x00273828 Perl_runops_standard + 88
22  libperl.dylib            	0x00208b3c perl_run + 524
23  perl                     	0x00002a10 main + 240
24  perl                     	0x0000289c _start + 760
25  perl                     	0x000025a0 start + 48

Thread 0 crashed with PPC Thread State 64:
  srr0: 0x0000000090131a80 srr1: 0x000000000200f030                       
vrsave: 0x0000000000000000
    cr: 0x44422242          xer: 0x0000000000000004   lr: 0x00000000902c580c 
ctr: 0x0000000000000004
    r0: 0x0000000000000bf0   r1: 0x00000000bfffb820   r2: 0x000000000000028a  
r3: 0x0000000000000000
    r4: 0x0000000090342410   r5: 0x0000000000000000   r6: 0x0000000000000001  
r7: 0x00000000fffff420
    r8: 0x0000000000000004   r9: 0x0000000000000010  r10: 0x0000000090001410 
r11: 0x0000000042422248
   r12: 0x00000000901319a0  r13: 0x0000000000000161  r14: 0x0000000016ee5d71 
r15: 0x0000000000000161
   r16: 0x0000000016ef8822  r17: 0x000000000342b960  r18: 0x00000000000001fa 
r19: 0x0000000000000000
   r20: 0x000000000342bdf0  r21: 0x0000000000000001  r22: 0x0000000000000000 
r23: 0x0000000000000001
   r24: 0x0000000000000000  r25: 0x0000000000103510  r26: 0x00000000a0285670 
r27: 0x00000000bfffd0f0
   r28: 0x00000000bfffd0f4  r29: 0x0000000000000001  r30: 0x0000000000000004 
r31: 0x00000000902c5670

Binary Images Description:
    0x1000 -     0x3fff perl 	/usr/local/perl5/bin/perl
   0x1a000 -    0x1efff Socket.bundle 
/usr/local/perl_libs/privlib/darwin-thread-multi-2level/auto/Socket/Socket.bundle
   0x21000 -    0x23fff IO.bundle 
/usr/local/perl_libs/privlib/darwin-thread-multi-2level/auto/IO/IO.bundle
   0x26000 -    0x2bfff Socket6.bundle 
/usr/local/perl_libs/sitelib/darwin-thread-multi-2level/auto/Socket6/Socket6.bundle
   0x33000 -    0x33fff Hostname.bundle 
/usr/local/perl_libs/privlib/darwin-thread-multi-2level/auto/Sys/Hostname/Hostname.bundle
   0x36000 -    0x38fff Fcntl.bundle 
/usr/local/perl_libs/privlib/darwin-thread-multi-2level/auto/Fcntl/Fcntl.bundle
   0x3b000 -    0x54fff POSIX.bundle 
/usr/local/perl_libs/privlib/darwin-thread-multi-2level/auto/POSIX/POSIX.bundle
   0x59000 -    0x5bfff Base64.bundle 
/usr/local/perl_libs/privlib/darwin-thread-multi-2level/auto/MIME/Base64/Base64.bundle
   0x5e000 -    0x66fff Parser.bundle 
/usr/local/perl_libs/sitelib/darwin-thread-multi-2level/auto/HTML/Parser/Parser.bundle
   0x72000 -    0x73fff DNS.bundle 
/usr/local/perl_libs/sitelib/darwin-thread-multi-2level/auto/Net/DNS/DNS.bundle
   0x7e000 -    0x7ffff Cwd.bundle 
/usr/local/perl_libs/privlib/darwin-thread-multi-2level/auto/Cwd/Cwd.bundle
   0x82000 -    0x85fff HiRes.bundle 
/usr/local/perl_libs/privlib/darwin-thread-multi-2level/auto/Time/HiRes/HiRes.bundle
   0x88000 -    0x8bfff Syslog.bundle 
/usr/local/perl_libs/privlib/darwin-thread-multi-2level/auto/Sys/Syslog/Syslog.bundle
   0xa6000 -    0xacfff Util.bundle 
/usr/local/perl_libs/privlib/darwin-thread-multi-2level/auto/List/Util/Util.bundle
   0xed000 -    0xf0fff SHA1.bundle 
/usr/local/perl_libs/sitelib/darwin-thread-multi-2level/auto/Digest/SHA1/SHA1.bundle
  0x205000 -   0x316fff libperl.dylib 
/usr/local/perl_libs/privlib/darwin-thread-multi-2level/CORE/libperl.dylib
  0x3c3000 -   0x3cefff DB_File.bundle 
/usr/local/perl_libs/privlib/darwin-thread-multi-2level/auto/DB_File/DB_File.bundle
  0x705000 -   0x7bcfff libdb-4.3.dylib 	/usr/local/berkeley-db/lib/libdb-4.3.dylib
 0xa000000 -  0xa0a3fff com.tcltk.tcllibrary 8.5a3
/Library/Frameworks/Tcl.framework/Versions/8.5/Tcl
0x8fe00000 - 0x8fe52fff dyld 45.3	/usr/lib/dyld
0x90000000 - 0x901bbfff libSystem.B.dylib 	/usr/lib/libSystem.B.dylib
0x9028d000 - 0x90366fff com.apple.CoreFoundation 6.4.6 (368.27)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
0x908e5000 - 0x909e7fff libicucore.A.dylib 	/usr/lib/libicucore.A.dylib
0x90b74000 - 0x90b86fff libauto.dylib 	/usr/lib/libauto.dylib
0x96112000 - 0x96117fff libmathCommon.A.dylib 	/usr/lib/system/libmathCommon.A.dylib
0x9ea3a000 - 0x9ea45fff libgcc_s.1.dylib 	/usr/lib/libgcc_s.1.dylib
0x9ff52000 - 0x9ffd6fff libobjc.A.dylib 	/usr/lib/libobjc.A.dylib
======================================================
Comment 1 openmacnews 2006-09-14 21:27:41 UTC
figured out the perl_debugger ...

stepping through 'spamd' with perl_debugger, (actually a working copy i've named
'spamd_test.pl'), i follow into:

		sub daemonize {
		  # Pretty command line in ps
		  $0 = join (' ', $ORIG_ARG0, @ORIG_ARGV) unless would_log("dbg");
		
		  # be a nice daemon and chdir to the root so we don't block any
		  # unmount attempts
		  chdir '/' or die "spamd: cannot chdir to /: $!\n";
		
		  # Redirect in and out to the bit bucket
		  open STDIN,  "</dev/null" or die "spamd: cannot read from /dev/null: $!\n";
		  open STDOUT, ">/dev/null" or die "spamd: cannot write to /dev/null: $!\n";
		
		  # Remove the stderr logger
		  Mail::SpamAssassin::Logger::remove('stderr');
		
		  # Here we go...
2140:	  defined( my $pid = fork ) or die "spamd: cannot fork: $!\n";
2141:	  exit if $pid;
2142:	  setsid or die "spamd: cannot start new session: $!\n";
2143:	
2144:	  # Now we can redirect the errors, too.
2145:	  open STDERR, '>&STDOUT' or die "spamd: cannot duplicate stdout: $!\n";
2146:	
2147:	  dbg("spamd: successfully daemonized");
	}


i can bkpt *cleanly* TO the line 2140:

	  DB<1> c 2140
	main::daemonize(./spamd_test.pl:2140):
	2140:     defined( my $pid = fork ) or die "spamd: cannot fork: $!\n";
	  DB<2> 

and, if i then bkpt to line 2147:

	  DB<2> c 2147
	Debugged program terminated.  Use q to quit or R to restart,
	  use o inhibit_exit to avoid stopping after program termination,
	  h q, h R or h o to get additional info.  
	  DB<3> 


i get the crash:

	Sep 14 14:23:26 server crashdump[21963]: perl crashed
	Sep 14 14:23:27 server crashdump[21963]: crash report written to:
/Library/Logs/CrashReporter/perl.crash.log

as before ...

	Exception:  EXC_BAD_ACCESS (0x0001)
	Codes:      KERN_PROTECTION_FAILURE (0x0002) at 0x00000000
	
	Thread 0 Crashed:
	0   libSystem.B.dylib        	0x90131a80 bcmp + 224
	1   com.apple.CoreFoundation 	0x902c580c __CFInitialize + 420
	2   dyld                     	0x8fe15660
ImageLoaderMachO::doInitialization(ImageLoader::LinkContext const&) + 672
	3   dyld                     	0x8fe0bbe8 
	...


if however, i bkpt to 2140, then try to single-step:

	  DB<1> c 2140
	main::daemonize(./spamd_test.pl:2140):
	2140:     defined( my $pid = fork ) or die "spamd: cannot fork: $!\n";
	  DB<2> s
	######### Forked, but do not know how to create a new TTY. #########
	  Since two debuggers fight for the same TTY, input is severely entangled.
	
	main::daemonize(./spamd_test.pl:2141):
	2141:     exit if $pid;
	  DB<2>   I know how to switch the output to a different window in xterms
	  and OS/2 consoles only.  For a manual switch, put the name of the created TTY
	  in $DB::fork_TTY, or define a function DB::get_fork_TTY() returning this.
	
	  On UNIX-like systems one can get the name of a TTY for the given window
	  by typing tty, and disconnect the shell from TTY by sleep 1000000.
	
	main::daemonize(./spamd_test.pl:2141):
	2141:     exit if $pid;
		{pid=21967}  DB<2> s
	Mail::SpamAssassin::Logger::CODE(0x18bf8f0)(/usr/local/perl_libs/sitelib/Mail/SpamAssassin/Logger.pm:319):
	319:      close_log();
	  DB<2> s
	Mail::SpamAssassin::Logger::close_log(/usr/local/perl_libs/sitelib/Mail/SpamAssassin/Logger.pm:313):
	313:      while (my ($name, $object) = each %{ $LOG_SA{method} }) {
	  DB<2> s
	Mail::SpamAssassin::Logger::close_log(/usr/local/perl_libs/sitelib/Mail/SpamAssassin/Logger.pm:313):
	313:      while (my ($name, $object) = each %{ $LOG_SA{method} }) {
	  DB<2> s
	Mail::SpamAssassin::Logger::close_log(/usr/local/perl_libs/sitelib/Mail/SpamAssassin/Logger.pm:314):
	314:        $object->close_log();
	  DB<2> s
	Mail::SpamAssassin::Logger::Syslog::close_log(/usr/local/perl_libs/sitelib/Mail/SpamAssassin/Logger/Syslog.pm:207):
	207:      my ($self) = @_;
	  DB<2> s
	Mail::SpamAssassin::Logger::Syslog::close_log(/usr/local/perl_libs/sitelib/Mail/SpamAssassin/Logger/Syslog.pm:209):
	209:      closelog();
	  DB<2> s
	Sys::Syslog::closelog(/usr/local/perl_libs/privlib/darwin-thread-multi-2level/Sys/Syslog.pm:133):
	133:        $facility = $ident = '';
	  DB<2> s
	Sys::Syslog::closelog(/usr/local/perl_libs/privlib/darwin-thread-multi-2level/Sys/Syslog.pm:134):
	134:        disconnect_log();
	  DB<2> s
	Sys::Syslog::disconnect_log(/usr/local/perl_libs/privlib/darwin-thread-multi-2level/Sys/Syslog.pm:628):
	628:        $connected = 0;
	  DB<2> s
	Sys::Syslog::disconnect_log(/usr/local/perl_libs/privlib/darwin-thread-multi-2level/Sys/Syslog.pm:629):
	629:        $syslog_send = undef;
	  DB<2> s
	Sys::Syslog::disconnect_log(/usr/local/perl_libs/privlib/darwin-thread-multi-2level/Sys/Syslog.pm:631):
	631:        if($current_proto eq 'native') {
	  DB<2> s
	Sys::Syslog::disconnect_log(/usr/local/perl_libs/privlib/darwin-thread-multi-2level/Sys/Syslog.pm:636):
	636:        return close SYSLOG;
	  DB<2> s
	Mail::SpamAssassin::Logger::close_log(/usr/local/perl_libs/sitelib/Mail/SpamAssassin/Logger.pm:313):
	313:      while (my ($name, $object) = each %{ $LOG_SA{method} }) {
	  DB<2> s
	Debugged program terminated.  Use q to quit or R to restart,
	  use o inhibit_exit to avoid stopping after program termination,
	  h q, h R or h o to get additional info.  
	  DB<2> q
	/usr/ports/temp  > main::daemonize(./spamd_test.pl:2142):
	2142:     setsid or die "spamd: cannot start new session: $!\n";
	{pid=21967}  DB<2> 


and, atm, not sure what to make of that ...  :-/
Comment 2 Theo Van Dinter 2006-09-14 21:39:05 UTC
fwiw, this has been discussed a bit on the irc channel.  the problems started
occuring after upgrading a bunch of modules via the CPAN shell's "r" command.

if I ignore the module upgrades, it sounds like a perl bug -- perl shouldn't be
crashing on any of the standard statements that it seems to be crashing on.  but
if the problems only started after the modules were upgraded (and not perl being
upgraded), it sounds XS related somehow.

I've recommended trying to rollback the modules that were upgraded, or since
this is apparently a custom perl install, make a new clean version, don't
upgrade any of the standard modules, and install just enough extra modules to
get SA functional, then see what happens.

FWIW, I can run spamd from trunk on my OS X laptop w/ standard perl 5.8.6
install without issue.  I also tried upgrading HTML::Tagset, HTML::Parser,
Digest::SHA1, and Net::DNS to the version that he has on his machine, and things
continue to work fine.

BTW: on the irc channel I said there were 3 ways for perl to explode, but
there's really at least 5, though none of them are SA related:

- hardware problem
- perl binary issue
- perl threading issue
- perl XS module issue
- ulimits (memory limits definitely cause perl to have problems)
- compiler issue (can cause above binary/XS issues)
Comment 3 openmacnews 2006-09-14 21:59:25 UTC
> problems started occuring after upgrading a bunch of modules via the CPAN
shell's "r" command.

that is true.

and, to complicate matters, when i'd upgraded, i did "cpan> r", then updated
those that needed updating were available ...

since then, i've rebuilt from scratch ... so my builds now have all the latest
modules.

i.e., i don't have the cpan module version history available ...

> if the problems only started after the modules were upgraded (and not perl being
upgraded), it sounds XS related somehow.
> I've recommended trying to rollback the modules that were upgraded, or since
this is apparently a custom perl install, make a new clean version, don't
upgrade any of the standard modules, and install just enough extra modules to
get SA functional, then see what happens.

fyi, i've been running perl 588 for ages on these boxes ... until the last
couple of days, quite successfully with SA-head, as well.

> FWIW, I can run spamd from trunk on my OS X laptop w/ standard perl 5.8.6
install without issue.  I also tried upgrading HTML::Tagset, HTML::Parser,
Digest::SHA1, and Net::DNS to the version that he has on his machine, and things
continue to work fine.

i've also reproduced the crash on two OSX-out-of-the-box boxes, with Apple's
perl 586.  To be fair, the details of the crash are different, and I have not
started tracing through a 'spamd' traversal with *that* perl version ...

> BTW: on the irc channel I said there were 3 ways for perl to explode, but
there's really at least 5, though none of them are SA related:

ok.

> - hardware problem

this is occurring/reproducible on several different boxes.

all, however are 'just' PowerPC (G#s & G$s ... no MacIntels)

> - perl binary issue
> - perl threading issue

again, this is the 'same' perl core that i've been using for awhile

> - perl XS module issue

possible, of course, ... 

> - ulimits (memory limits definitely cause perl to have problems)

fwiw, on all boxes:

	% ulimit -n
		1024

> - compiler issue (can cause above binary/XS issues)

dunno ...


in general, i understand that the inclination is to 'blame perl' ...

in this case, tho, i simply see no problems with perl on any box with any other app.

ONLY in the specific case of "spamd --daemonize", and then the problem traces to
daemon code ...
Comment 4 openmacnews 2006-09-14 22:05:58 UTC
just fwiw, changing to:

% ulimit -n
  12288

has, alas, no effect ...
Comment 5 openmacnews 2006-09-15 16:31:31 UTC
blamed on perl; stated as 'not related to SA'