This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Integrate:
authorNicholas Clark <nick@ccl4.org>
Sat, 24 Sep 2005 15:29:40 +0000 (15:29 +0000)
committerNicholas Clark <nick@ccl4.org>
Sat, 24 Sep 2005 15:29:40 +0000 (15:29 +0000)
(the threads parts of)
[ 24175]
Casting to/from (void *) sufficient to make a C++ compiler happy.

[ 25123]
Subject: Re: Scalar leaked in 'local $0' under ithreads + taint mode
From: Steve Hay <steve.hay@uk.radan.com>
Date: Mon, 11 Jul 2005 13:29:37 +0100
Message-ID: <42D26631.1070500@uk.radan.com>

[ 25307]
Subject: [PATCH] make threads.xs emit warnings properly
From: Tassilo von Parseval <tassilo.von.parseval@rwth-aachen.de>
Date: Aug 7, 2005 7:10 AM
Message-id: <20050807051041.GA3924@ethan>

[ 25442]
Holding a mutex then croak()ing strikes me as deadlock.
p4raw-link: @25442 on //depot/perl: 3307a0c55ca8bb4e0c9a7d4f6856fee33d4f8701
p4raw-link: @25307 on //depot/perl: 4447dfc12157eb387a12bf297bbc4f4c8c49a7a6
p4raw-link: @25123 on //depot/perl: d419787aba7043c27741cb1497c553fcd3241d02
p4raw-link: @24175 on //depot/perl: 8f77bfdb1ccc695676a1e8260398001deb0b18cf

p4raw-id: //depot/maint-5.8/perl@25594
p4raw-integrated: from //depot/perl@25593 'copy in'
ext/threads/threads.pm (@24248..) 'merge in' pod/perldiag.pod
(@25268..)
p4raw-integrated: from //depot/perl@24175 'ignore'
ext/threads/threads.xs (@23121..) 'merge in'
ext/threads/shared/shared.xs (@23998..)

ext/threads/shared/shared.xs
ext/threads/threads.pm
ext/threads/threads.xs
pod/perldiag.pod

index a647186..aa1dcf2 100644 (file)
@@ -304,7 +304,7 @@ Perl_sharedsv_associate(pTHX_ SV **psv, SV *ssv, shared_sv *data)
                ssv = newSV(0);
                SvREFCNT(ssv) = 0;
            }
-           data = PerlMemShared_malloc(sizeof(shared_sv));
+           data = (shared_sv *) PerlMemShared_malloc(sizeof(shared_sv));
            Zero(data,1,shared_sv);
            SHAREDSvPTR(data) = ssv;
            /* Tag shared side SV with data pointer */
index 22180ad..c320d1c 100755 (executable)
@@ -50,7 +50,7 @@ our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
 our @EXPORT = qw(
 async  
 );
-our $VERSION = '1.06';
+our $VERSION = '1.07';
 
 
 # || 0 to ensure compatibility with previous versions
index 828f7f4..272a2a6 100755 (executable)
@@ -96,6 +96,7 @@ Perl_ithread_destruct (pTHX_ ithread* thread, const char *why)
         PerlInterpreter *freeperl = NULL;
        MUTEX_LOCK(&thread->mutex);
        if (!thread->next) {
+           MUTEX_UNLOCK(&thread->mutex);
            Perl_croak(aTHX_ "panic: destruct destroyed thread %p (%s)",thread, why);
        }
        if (thread->count != 0) {
@@ -168,8 +169,9 @@ Perl_ithread_hook(pTHX)
     int veto_cleanup = 0;
     MUTEX_LOCK(&create_destruct_mutex);
     if (aTHX == PL_curinterp && active_threads != 1) {
-       Perl_warn(aTHX_ "A thread exited while %" IVdf " threads were running",
-                                               (IV)active_threads);
+       if (ckWARN_d(WARN_THREADS))
+           Perl_warn(aTHX_ "A thread exited while %" IVdf " threads were running",
+                                                     (IV)active_threads);
        veto_cleanup = 1;
     }
     MUTEX_UNLOCK(&create_destruct_mutex);
@@ -304,7 +306,7 @@ Perl_ithread_run(void * arg) {
                  SV *sv = POPs;
                  av_store(params, i, SvREFCNT_inc(sv));
                }
-               if (SvTRUE(ERRSV)) {
+               if (SvTRUE(ERRSV) && ckWARN_d(WARN_THREADS)) {
                    Perl_warn(aTHX_ "thread failed to start: %" SVf, ERRSV);
                }
                FREETMPS;
@@ -388,7 +390,7 @@ Perl_ithread_create(pTHX_ SV *obj, char* classname, SV* init_function, SV* param
 
 
        MUTEX_LOCK(&create_destruct_mutex);
-       thread = PerlMemShared_malloc(sizeof(ithread));
+       thread = (ithread *) PerlMemShared_malloc(sizeof(ithread));
        if (!thread) {  
            MUTEX_UNLOCK(&create_destruct_mutex);
            PerlLIO_write(PerlIO_fileno(Perl_error_log),
@@ -566,14 +568,12 @@ Perl_ithread_self (pTHX_ SV *obj, char* Class)
 void
 Perl_ithread_CLONE(pTHX_ SV *obj)
 {
- if (SvROK(obj))
-  {
-   ithread *thread = SV_to_ithread(aTHX_ obj);
-  }
- else
-  {
-   Perl_warn(aTHX_ "CLONE %" SVf,obj);
-  }
+    if (SvROK(obj)) {
+       ithread *thread = SV_to_ithread(aTHX_ obj);
+    }
+    else if (ckWARN_d(WARN_THREADS)) {
+       Perl_warn(aTHX_ "CLONE %" SVf,obj);
+    }
 }
 
 AV*
@@ -760,7 +760,7 @@ BOOT:
        MUTEX_INIT(&create_destruct_mutex);
        MUTEX_LOCK(&create_destruct_mutex);
        PL_threadhook = &Perl_ithread_hook;
-       thread  = PerlMemShared_malloc(sizeof(ithread));
+       thread  = (ithread *) PerlMemShared_malloc(sizeof(ithread));
        if (!thread) {
            PerlLIO_write(PerlIO_fileno(Perl_error_log),
                          PL_no_mem, strlen(PL_no_mem));
index 6600a4c..7a5f5eb 100644 (file)
@@ -193,7 +193,7 @@ know which context to supply to the right side.
 
 =item A thread exited while %d threads were running
 
-(W) When using threaded Perl, a thread (not necessarily the main
+(W threads)(S) When using threaded Perl, a thread (not necessarily the main
 thread) exited while there were still other threads running.
 Usually it's a good idea to first collect the return values of the
 created threads by joining them, and only then exit from the main
@@ -3740,7 +3740,7 @@ target of the change to
 
 =item thread failed to start: %s
 
-(S) The entry point function of threads->create() failed for some reason.
+(W threads)(S) The entry point function of threads->create() failed for some reason.
 
 =item 5.005 threads are deprecated