Bug#902779: perl-debug: XS code built for perl doesn't work with debugperl

2018-07-08 Thread Niko Tyni
Control: unblock 902557 with -1

On Mon, Jul 02, 2018 at 09:57:26PM +0300, Niko Tyni wrote:
> On Sat, Jun 30, 2018 at 10:06:34PM +0300, Niko Tyni wrote:
> > Package: perl-debug
> > Version: 5.28.0-1
> > Severity: normal
> > User: debian-p...@lists.debian.org
> > Usertags: perl-5.28-transition
> > 
> > I noticed that many of our XS module packages are incompatible
> > with debugperl after being rebuilt for 5.28. Consider:

> I see two obvious avenues for fixing this:
> 
> A) move the -DDEBUGGING check in EXTEND to run time, for instance by
>calling a function that's a no-op in non-DEBUGGING interpreters. This
>has a runtime cost, but I'm not sure how significant. We need to ask
>upstream.

Upstream says runtime costs for non-DEBUGGING builds are unacceptable.

> B) disable the check on the DEBUGGING side altogether. There's currently
>no facility to do this short of patching the code.

So we need to do this. Should be just a matter of #ifdef'ing out the
two places where the 'failed to extend arg stack' panic is triggered.

I don't see a compelling need to patch away all the hwm handling -
it does slow down debugperl a bit but that's not a concern I think.

> If A) is judged adequate upstream, we should do that before the 5.28 >
transition so that we don't have to rebuild all the XS modules afterwards.
> I'm therefore marking this as a transition blocker for now.

Since we're taking B), it doesn't matter if it's done before or after
the transition: the change only affects the debugperl side and not the
XS modules. I'm therefore removing the blocker mark.

Longer term, it looks possible that we can't keep debugperl able to load
non-DEBUGGING XS modules. Such a combination isn't properly supported
or tested upstream. I'm not sure how much of a concern this really is
for our users, and how hard we should try.
-- 
Niko



Bug#902779: perl-debug: XS code built for perl doesn't work with debugperl

2018-07-02 Thread Niko Tyni
Control: block 902557 with -1

On Sat, Jun 30, 2018 at 10:06:34PM +0300, Niko Tyni wrote:
> Package: perl-debug
> Version: 5.28.0-1
> Severity: normal
> User: debian-p...@lists.debian.org
> Usertags: perl-5.28-transition
> 
> I noticed that many of our XS module packages are incompatible
> with debugperl after being rebuilt for 5.28. Consider:
> 
>  # debugperl -MDateTime -e 'print DateTime->today'
>  panic: XSUB DateTime::_rd2ymd (DateTime.c) failed to extend arg stack: 
> base=55b63e6b3b48, sp=55b63e6b3b80, hwm=55b63e6b3b68
> 
> This panic is due to a new -DDEBUGGING check that guards the XS function
> argument stack, making sure that XS code extends the stack properly when
> it pushes elements there.
> 
> However, I believe the check isn't currently working properly when
> the XS code is built with a non-DDEBUGGING perl.h and then run with a
> -DDEBUGGING perl build.

So, I see the EXTEND macro in pp.h is instrumented to make a note of
how far the stack is supposed to extend, and this 'high-water mark'
(hwm) is compared to the stack pointer after calling an XSUB. If the
XSUB has pushed more elements than it declared with EXTEND (or didn't
call EXTEND at all), the above panic will result.

The problem is that EXTEND only updates the high-water mark when the
DEBUGGING preprocessor symbol is defined (i.e. the choice is done at
compile time.) If the XS module is built without -DDEBUGGING in ccflags
(as is the case for Debian XS module packages), the high-water mark
doesn't get updated.  If the interpreter side is built with -DDEBUGGING
(as our debugperl is), it will still check the hwm.

I see two obvious avenues for fixing this:

A) move the -DDEBUGGING check in EXTEND to run time, for instance by
   calling a function that's a no-op in non-DEBUGGING interpreters. This
   has a runtime cost, but I'm not sure how significant. We need to ask
   upstream.

B) disable the check on the DEBUGGING side altogether. There's currently
   no facility to do this short of patching the code.

If A) is judged adequate upstream, we should do that before the 5.28
transition so that we don't have to rebuild all the XS modules afterwards.
I'm therefore marking this as a transition blocker for now.

Otherwise we need to do B) and lose some useful debugging checks.
-- 
Niko Tyni   nt...@debian.org



Bug#902779: perl-debug: XS code built for perl doesn't work with debugperl

2018-06-30 Thread Niko Tyni
Package: perl-debug
Version: 5.28.0-1
Severity: normal
User: debian-p...@lists.debian.org
Usertags: perl-5.28-transition

I noticed that many of our XS module packages are incompatible
with debugperl after being rebuilt for 5.28. Consider:

 # debugperl -MDateTime -e 'print DateTime->today'
 panic: XSUB DateTime::_rd2ymd (DateTime.c) failed to extend arg stack: 
base=55b63e6b3b48, sp=55b63e6b3b80, hwm=55b63e6b3b68

 # printf '\n\n\n' | debugperl 
-MXML::LibXML -e 
'XML::LibXML->new->parse_fh(*STDIN)->documentElement->childNodes; '
 panic: XSUB XML::LibXML::Node::_childNodes (LibXML.c) failed to extend arg 
stack: base=561827c61b48, sp=561827c61b68, hwm=561827c61b60

This panic is due to a new -DDEBUGGING check that guards the XS function
argument stack, making sure that XS code extends the stack properly when
it pushes elements there.

However, I believe the check isn't currently working properly when
the XS code is built with a non-DDEBUGGING perl.h and then run with a
-DDEBUGGING perl build.

Will take this upstream once I've investigated it properly.
-- 
Niko Tyni   nt...@debian.org