From dd97cb7a7447313dbc1da65104786fe03ede7c8d Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Fri, 10 Feb 2017 01:29:28 -0600 Subject: [PATCH] PERLUAFS: Modernize lang-specific swig typemaps Currently, our swig bindings for PERLUAFS define a couple of typemaps like so: %typemap(in, numinputs=1, perl5) (char *READBUF, int LENGTH) { [...] } Embedding the target language name in the typemap arguments is a very old way of specifying what language the typemap is for; they were removed after swig 1.1. With swig 3.0.x releases (and possibly others), the specific combination of this deprecated syntax and some other features we're using causes a segfault. That's clearly a bug in swig, but we shouldn't be using the deprecated syntax anyway. Update this to instead use preprocessor symbols to specify language-specific typemaps (#ifdef SWIGPERL). We only actually define these for perl right now, so make sure to throw an error if we're not running for perl. FIXES 134103 Change-Id: I14264a2dfada53d99413808ed5d60b79b1ee44f3 Reviewed-on: https://gerrit.openafs.org/12517 Tested-by: BuildBot Reviewed-by: Michael Meffie Reviewed-by: Benjamin Kaduk --- src/libuafs/ukernel_swig.i | 12 ++++++++---- 1 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/libuafs/ukernel_swig.i b/src/libuafs/ukernel_swig.i index bf6ce41..94fc6d4 100644 --- a/src/libuafs/ukernel_swig.i +++ b/src/libuafs/ukernel_swig.i @@ -16,8 +16,8 @@ * For each language you want a binding for, there are two typemaps you * must define for that language, since SWIG does not handle them natively. * These are the 'in' typemap for READBUF and LENGTH, and the 'argout' - * typemap for READBUF. Search this file for 'perl5' to see existing ones - * for the Perl 5 bindings. + * typemap for READBUF. Search this file for 'SWIGPERL' to see existing ones + * for the Perl bindings. */ %module "AFS::ukernel" @@ -78,14 +78,15 @@ extern int uafs_Run(void); * (Reading in a binary buffer from e.g. uafs_write is already handled natively * by SWIG. Fancy that.) */ -%typemap(in, numinputs=1, perl5) (char *READBUF, int LENGTH) { +#if defined(SWIGPERL) +%typemap(in, numinputs=1) (char *READBUF, int LENGTH) { if (!SvIOK($input)) { SWIG_croak("expected an integer"); } $2 = SvIV($input); Newx($1, $2, char); } -%typemap(argout, numinputs=1, perl5) char *READBUF { +%typemap(argout, numinputs=1) char *READBUF { /* some logic here copied from typemaps.i and/or SWIG itself, since I'm not * a perl dev */ @@ -105,6 +106,9 @@ extern int uafs_Run(void); Safefree($1); argvi++; } +#else +# error No READBUF typemap defined for the given language +#endif extern int uafs_mkdir(char *path, int mode); extern int uafs_chdir(char *path); -- 1.7.1