summaryrefslogtreecommitdiff
path: root/perl.c
diff options
context:
space:
mode:
authorFlorian Ragwitz <rafl@debian.org>2010-07-20 22:58:24 +0200
committerFlorian Ragwitz <rafl@debian.org>2010-07-26 15:48:18 +0200
commit1e8125c621275d18c74bc8dae3bfc3c03929fe1e (patch)
tree787df37aad96d973175f1218677b312e8c8f261e /perl.c
parent3b462feda21356499e651643c80692cc1c5e6787 (diff)
downloadperl-1e8125c621275d18c74bc8dae3bfc3c03929fe1e.tar.gz
Check API compatibility when loading xs modules
This adds PL_apiversion, allowing the API version of a running interpreter to be introspected. It is used in the new XS_APIVERSION_BOOTCHECK macro, which is added to the _boot function of every XS module, to compare it against the API version the module has been compiled against. If the versions do not match, an exception is thrown. This doesn't fully prevent binary incompatible extensions to be loaded. It merely compares PERL_API_* between compile- and runtime, and does not attempt to solve the problem of identifying binary incompatible perls with the same API version (i.e. the same perl version configured with and without DEBUGGING).
Diffstat (limited to 'perl.c')
-rw-r--r--perl.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/perl.c b/perl.c
index d52d79f41e..404372c4dd 100644
--- a/perl.c
+++ b/perl.c
@@ -348,6 +348,7 @@ perl_construct(pTHXx)
PL_stashcache = newHV();
PL_patchlevel = newSVpvs("v" PERL_VERSION_STRING);
+ PL_apiversion = newSVpvs("v" PERL_API_VERSION_STRING);
#ifdef HAS_MMAP
if (!PL_mmap_page_size) {
@@ -877,6 +878,7 @@ perl_destruct(pTHXx)
Safefree(PL_inplace);
PL_inplace = NULL;
SvREFCNT_dec(PL_patchlevel);
+ SvREFCNT_dec(PL_apiversion);
if (PL_e_script) {
SvREFCNT_dec(PL_e_script);