Croak on non ref to shared methods instead of segfault.
Artur Bergman [Mon, 21 Apr 2003 17:05:31 +0000 (17:05 +0000)]
This can really only happen for &share("string").

p4raw-id: //depot/perl@19299

ext/threads/shared/shared.xs

index 3e7916f..9e0f73b 100644 (file)
@@ -965,6 +965,8 @@ SV*
 share(SV *ref)
        PROTOTYPE: \[$@%]
        CODE:
+       if(!SvROK(ref))
+            Perl_croak(aTHX_ "Argument to share needs to be passed as ref");
        ref = SvRV(ref);
        if(SvROK(ref))
            ref = SvRV(ref);
@@ -978,6 +980,8 @@ lock_enabled(SV *ref)
        PROTOTYPE: \[$@%]
        CODE:
        shared_sv* shared;
+       if(!SvROK(ref))
+            Perl_croak(aTHX_ "Argument to lock needs to be passed as ref");
        ref = SvRV(ref);
        if(SvROK(ref))
            ref = SvRV(ref);
@@ -992,6 +996,8 @@ cond_wait_enabled(SV *ref)
        CODE:
        shared_sv* shared;
        int locks;
+       if(!SvROK(ref))
+            Perl_croak(aTHX_ "Argument to cond_wait needs to be passed as ref");
        ref = SvRV(ref);
        if(SvROK(ref))
            ref = SvRV(ref);
@@ -1022,6 +1028,8 @@ cond_signal_enabled(SV *ref)
        PROTOTYPE: \[$@%]
        CODE:
        shared_sv* shared;
+       if(!SvROK(ref))
+            Perl_croak(aTHX_ "Argument to cond_signal needs to be passed as ref");
        ref = SvRV(ref);
        if(SvROK(ref))
            ref = SvRV(ref);
@@ -1038,6 +1046,8 @@ cond_broadcast_enabled(SV *ref)
        PROTOTYPE: \[$@%]
        CODE:
        shared_sv* shared;
+       if(!SvROK(ref))
+            Perl_croak(aTHX_ "Argument to cond_broadcast needs to be passed as ref");
        ref = SvRV(ref);
        if(SvROK(ref))
            ref = SvRV(ref);