New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Overloaded integer constants are prematurely deallocated #15646
Comments
From trizenx@gmail.comThis is a bug report for perl from trizenx@gmail.com, It seems like there is a premature deallocation of integer overloaded Bellow is the code illustrating the issue: ####################################### package Foo; #use Math::BigNum qw(:constant); # correct (perl=5.18.4) ; segfault sub new { sub set { while (my ($k, $v) = each %kv) { sub show { printf "--- %s ---\n", $self->{name}; my %kloop = %$kv; sub DESTROY { #my $foo; # NOTE: uncommenting this line, fixes $foo = Foo->new(name => 'implicit'); ######################### END-OF-CODE ######################### The output under perl=5.24.0 with `Math::GMP qw(:constant)` is: --- explicit --- Flags: Site configuration information for perl 5.24.0: Configured by builduser at Thu Sep 8 13:45:49 CEST 2016. Summary of my perl5 (revision 5 version 24 subversion 0) configuration: Platform: @INC for perl 5.24.0: Environment for perl 5.24.0: PATH=/usr/lib/ccache/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/usr/share/perl6/vendor/bin |
From @jkeenanOn Fri Oct 07 05:11:42 2016, trizenx@gmail.com wrote:
Thanks for the bug report. I suspect this is going to require input from others to untangle. If I read your post correctly, you are testing 3 scenarios differentiated by which of the 'use' statements is uncommented -- correct? Here are my results: 1. use Math::BigNum qw(:constant); # correct (perl=5.18.4) ; segfault (perl>=5.24.0) 2. $ head -5 129825-constant-bignum.pl #use Math::BigNum qw(:constant); # correct (perl=5.18.4) ; segfault (perl>=5.24.0) $ perl 129825-constant-bignum.pl 3. #use Math::BigNum qw(:constant); # correct (perl=5.18.4) ; segfault (perl>=5.24.0) $ perl 129825-constant-bignum.pl So, in the one case where I can run your program (#3), I cannot reproduce your error. Thank you very much. -- |
The RT System itself - Status changed from 'new' to 'open' |
From trizenx@gmail.comOn Fri Oct 07 07:29:57 2016, jkeenan wrote:
Adding a "1;" after the method DESTROY, the bug is reproducible in the third case as well. ############## sub DESTROY { 1; # this triggers the bug with Math::GMP #... For the second case of "bignum", the "Math::BigInt::GMP" module is required. |
From @iabynOn Fri, Oct 07, 2016 at 07:29:57AM -0700, James E Keenan via RT wrote:
I can reproduce the SEGV with use Math::BigNum qw(:constant). -- |
From zefram@fysh.orgDaniel Suteu wrote:
This doesn't happen on just any destruction, it's specifically during Where your destructor depends on the object being well-formed, you -zefram |
From @iabynOn Fri, Oct 07, 2016 at 04:17:16PM +0100, Dave Mitchell wrote:
The SEGV is due to a bug in the typemap for Math-GMPq-0.41. In particular these: MPQ If the passed arg isn't a ref, then it will unconditionally attempt to deref During global destruction, it's quite possible for a RV to be converted Changing $foo to be lexical causes it to be cleared during exit from the I should imagine that the other case, where it displays 'UNDEF' is due to -- |
From @sisyphus----- Original Message ----- [snip]
It's unclear to me exactly what the typemap should be specifying in order to (I'm the author of Math::GMPq - and of a number of other modules that use Cheers, |
From @iabynOn Fri, Oct 07, 2016 at 10:11:02PM +0100, Sisyphus wrote:
Well the problem is if an XS sub with that typemap is passed an arg which $var = SvROK($arg) ? INT2PTR($type, SvIVX(SvRV($arg))) : NULL which will set $var to NULL pointer in that case. It's then up to the Or you could have the code in the typemap expression croak. -- |
From @sisyphus----- Original Message -----
Thanks Dave. I'll have another think about if/how I want to handle this. What I don't like is that something like I guess the SvROK() call is fairly cheap, but for general purposes it Anyway ... something to think about when I get home in a couple of weeks. Cheers, |
@iabyn - Status changed from 'open' to 'rejected' |
Migrated from rt.perl.org#129825 (status was 'rejected')
Searchable as RT129825$
The text was updated successfully, but these errors were encountered: