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
threads sort crashes with sort subroutine (but not with sort block) #7372
Comments
From ajsavige@yahoo.com.auThe test program below demonstrates a threads-related crash on There has been some discussion of this interesting bug at: -----------snip------------snip------------snip----------------------- use strict; sub mycmp { length($b) <=> length($a) } sub do_one_thread { sub do_threads { # do_threads(1); # does not crash /-\ Flags: Site configuration information for perl v5.8.4: Configured by andrews at Sun Jun 6 11:34:57 2004. Summary of my perl5 (revision 5 version 8 subversion 4) configuration: Locally applied patches: @INC for perl v5.8.4: Environment for perl v5.8.4: Find local movie times and trailers on Yahoo! Movies. |
From ajsavige@yahoo.com.au--- Andrew Savige <perlbug-followup@perl.org> wrote:
I have analysed some sort crashes and have some more information. As will soon become obvious, the analysis below is written from the This is a typical crash: 1) Thread 1 is inside CALLRUNOPS (called from sortcv in pp_sort.c). 2) Thread 2 does a POPBLOCK/LEAVE scope as is exits pp_sort. 3) Thread 1 now executes the final leavesub OP inside CALLRUNOPS, 4) Thread 1 happily exits sortcv, but when it reenters it, there Point 3) above is a mystery to me, and I hope someone can shed some This is just a guess really, but pp_sort lines 1472/1473 look odd: SAVEVPTR(CvROOT(cv)->op_ppaddr); I am guessing that these two lines set ppaddr of the leavesub OP to In case you're interested, the original place where this crash was /-\ Find local movie times and trailers on Yahoo! Movies. |
From @iabynI've traced the location of this threads/sort segfault to some code SAVEVPTR(CvROOT(cv)->op_ppaddr); This is deeply, deeply, not thread-safe. It's supposed to turn the However, it's too late at night for me to work out how to fix this yet. Dave. -- |
The RT System itself - Status changed from 'new' to 'open' |
From @rgsDave Mitchell wrote:
That's a difficult problem because : |
From ajsavige@yahoo.com.auI've just done a full search of my perl install (perl-5.8.4 plus quite Luckily, it seems that sort subroutines are rarely used. /-\ Find local movie times and trailers on Yahoo! Movies. |
From @rgsTassilo von Parseval wrote:
Apparently not : from pp_sort.c, if (is_xsub) PAD_SET_CUR(CvPADLIST(cv), 1); |
From tassilo.parseval@post.rwth-aachen.deOn Tue, Jun 29, 2004 at 01:38:54PM +1000 Andrew Savige wrote:
FWIW, I have one module that exports sort-functions from a C library as Tassilo |
From ajsavige@yahoo.com.auTassilo von Parseval wrote:
I think you're OK. I've tested four cases (with 2 threads): Cases 3 and 4 never crash for me. Case 1 always crashes for me. When the smoke has cleared, I'd be happy to contribute a test case. /-\ Find local movie times and trailers on Yahoo! Movies. |
From tassilo.parseval@post.rwth-aachen.deOn Tue, Jun 29, 2004 at 09:39:25AM +0200 Rafael Garcia-Suarez wrote:
Oh, good. In this case you have my full blessing to do any Tassilo |
From @iabynOn Mon, Jun 28, 2004 at 09:32:23PM +0200, Rafael Garcia-Suarez wrote:
Hmm, I just tried fixing it in leavesub (see the untested diff below), and use Time::HiRes qw( usleep ualarm gettimeofday tv_interval ); sub f {}; $t = [gettimeofday]; pre-patch: 8.57977 post-patch: 8.78078 from I which conclude that fiddling with leavesub speeds it up. Don't you Dave. -- Inline Patch--- ../22960.ORIG/pp_hot.c Sat Jun 19 10:59:42 2004
+++ pp_hot.c Wed Jun 30 01:42:26 2004
@@ -2344,6 +2344,8 @@ PP(pp_leavesub)
register PERL_CONTEXT *cx;
SV *sv;
+ if (PL_curstackinfo->si_type == PERLSI_SORT && cxstack_ix == PL_sortcxix)
+ return Nullop;
POPBLOCK(cx,newpm);
cxstack_ix++; /* temporarily protect top context */
--- ../22960.ORIG/pp_sort.c Sat Jun 19 10:59:59 2004
+++ pp_sort.c Wed Jun 30 01:42:50 2004
@@ -1469,8 +1469,8 @@ PP(pp_sort)
PL_sortcop = (OP*)cv;
else {
PL_sortcop = CvSTART(cv);
- SAVEVPTR(CvROOT(cv)->op_ppaddr);
- CvROOT(cv)->op_ppaddr = PL_ppaddr[OP_NULL];
+ /* XXX SAVEVPTR(CvROOT(cv)->op_ppaddr);
+ CvROOT(cv)->op_ppaddr = PL_ppaddr[OP_NULL]; */
PAD_SET_CUR(CvPADLIST(cv), 1);
} |
From @rgsDave Mitchell wrote:
Funny thing, I have opposite results (8.31 average timing without the |
From @cpansproutOn Sun Jun 27 17:58:55 2004, davem@iabyn.com wrote:
I cannot reproduced this in 5.10.0, probably because commit |
@cpansprout - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#30333 (status was 'resolved')
Searchable as RT30333$
The text was updated successfully, but these errors were encountered: