develooper Front page | perl.perl5.porters | Postings from August 2012

Re: [perl #114198] XSPP warns of bad XS code in Dynaloader

Thread Previous | Thread Next
From:
Steffen Mueller
Date:
August 1, 2012 09:52
Subject:
Re: [perl #114198] XSPP warns of bad XS code in Dynaloader
Message ID:
50195ED5.7020904@steffen-mueller.net
On 07/19/2012 10:58 AM, bulk 88 (via RT) wrote:

> This bug ticket is 100% cosmetic. There are no runtime issues with
> it. While compiling perl 5.17 I noticed some warnings in the console.
> DynaLoader.xs is actually dl_win32.xs for me but I think this problem
> is in every dl_* file, I traced the XS code back to Paul Marquess in
> 1994,
> http://perl5.git.perl.org/perl.git/blob/a0d0e21ea6ea90a22318550944fe6cb09ae10cda:/ext/DynaLoader/dl_next.xs
> . Day 1 of DynaLoader. "dl.c" the predecessor to DynaLoader had a
> very different api than DynaLoader.

> I looked at the 2 lines, first is dl_load_file, which declares a
> void * return type through XSPP XS syntax, yet manually uses ST(0).
 > Second is dl_find_symbol which again declares a void * return type,
 > yet manually uses ST(0). Either use the XS return type the correct way
> with an OUTPUT section, or don't use the XS return type feature and
> use ST(*) and XSRETURN/XSRETURN_*/PPCODE and PUSH. This ticket is
> 100% cosmetic.

It was I who added that warning about missing OUTPUT sections. This was 
because it is all too easy to forget to add "OUTPUT: RETVAL" to any one 
of the gazillions XSUBs that use typemaps and people (including me) get 
it wrong all the time. As far as the XS documentation goes, RETVAL and 
an XS return type have no point without the OUTPUT section at all. The 
warning seemed a very useful diagnostic. In fact, I was going to attempt 
going one step further by making an "OUTPUT: RETVAL" implicit if RETVAL 
is used / there is a non-void XSUB return type. Didn't get to try it yet 
since it requires a CPAN smoke.

The code in DynaLoader IMO works incidentially, but relies on an XS 
implementation detail -- at least as far as the documented parts of XS 
are concerned. That's not too bad since it's core, but if we're going to 
keep the warning (which I still consider valuable), I think it's 
worthwhile to fix the warnings. Alas, it's per-architecture code, so 
mistakes will be tough to find for the implementer. :(

Best regards,
Steffen

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About