This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #121983] #error with ro ops and no threads
authorFather Chrysostomos <sprout@cpan.org>
Sat, 20 Sep 2014 07:43:28 +0000 (00:43 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sat, 20 Sep 2014 14:43:24 +0000 (07:43 -0700)
PERL_DEBUG_READONLY_OPS is designed to catch modifications of op trees
at run time, to make sure that perl is doing things safely under
threads.  (Op trees are shared between threads.)

On non-threaded perls, ops are modified regularly, which is perfectly
safe, so PERL_DEBUG_READONLY_OPS does not make any sense, and is guar-
anteed to crash.

Forcing a compilation error with cpp directives makes it obvious that
it is not intended for this PERL_DEBUG_READONLY_OPS mode to work with-
out USE_ITHREADS.

perl.h

diff --git a/perl.h b/perl.h
index d711b20..5615b96 100644 (file)
--- a/perl.h
+++ b/perl.h
@@ -2663,6 +2663,10 @@ typedef SV PADNAME;
 # define PERL_SAWAMPERSAND
 #endif
 
+#if defined(PERL_DEBUG_READONLY_OPS) && !defined(USE_ITHREADS)
+# error PERL_DEBUG_READONLY_OPS only works with ithreads
+#endif
+
 #include "handy.h"
 
 #if defined(USE_LARGE_FILES) && !defined(NO_64_BIT_RAWIO)