On Fri, May 11, 2012 at 04:52:33PM +0100, Dave Mitchell wrote: > On Fri, May 11, 2012 at 04:22:18PM +0100, Tim Bunce wrote: > > Dave, I'd be grateful if you could take a look at this since it > > seems to involve our recent changes and standard perl modules. > > I can reproduce. Am looking into it.
now fixed with the attached patch. Basically creating a thread from within another thread would cause a crash, because mg_ptr wasn't being updated during CV duplication: this field contains a pointer back to the CV to allow mg_dup to access it; after duplication it still pointed back to the original, so duping a dup caused the crash. -- Any [programming] language that doesn't occasionally surprise the novice will pay for it by continually surprising the expert. -- Larry Wall
Index: DBI.xs =================================================================== --- DBI.xs (revision 15303) +++ DBI.xs (working copy) @@ -283,6 +283,7 @@ CV *ncv = (CV*)ptr_table_fetch(PL_ptr_table, (cv)); (void)param; /* avoid 'unused variable' warning */ + mg->mg_ptr = (char *)ncv; ima = (dbi_ima_t*) CvXSUBANY(cv).any_ptr; Newx(nima, 1, dbi_ima_t); *nima = *ima; /* structure copy */ Index: t/35thrclone.t =================================================================== --- t/35thrclone.t (revision 15303) +++ t/35thrclone.t (working copy) @@ -52,6 +52,11 @@ cmp_ok($dbh->{Driver}->{Kids}, '==', 1, '... the Driver has one Kid') unless $DBI::PurePerl && ok(1); } + + # RT #77137: a thread created from a thread was crashing the + # interpreter + + threads->new(sub {})->join(); } # load up the threads