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
Disappearing object #6133
Comments
From @JuerdCreated by @JuerdGood morning (It has to be morning *somewhere*), With DBIx::Simple, users of at least Perl 5.6.1 and 5.8.0 get the following Even with a lot of stripping down, I wasn't able to get rid of this error. #!/usr/bin/perl -w sub connect { bless { dbi => DBI->connect(@_[1..$#_]) }, $_[0] } sub die { sub disconnect { sub DESTROY { package main; my $db = DBIx::Simple::Stripped->connect('DBI:SQLite:foo'); printf "In main code: The dbh is now: %s\n", defined $db->{dbi} ? $db->{dbi} : 'undef'; This outputs: The dbh (stored in $db->{dbi}) disappears between the END block's execution Things get even more interesting when the sub foo is commented out. It then Lines 8 and 20 are in the form of: I don't get how that can ever warn about using an uninitialized value in I'm puzzled. Please help :) This has only been tried on several Linux systems and one FreeBSD box. Greets, Juerd P.S. For now, I'll release a version of DBIx::Simple that disconnect()s Perl Info
|
From rick.delaney@rogers.comJuerd (via RT) <perlbug-followup@perl.org> writes:
Two different variables.
I don't think order of destruction is guaranteed during the global phase.
Really of the form: printf "%s", defined $foo[0] ? $foo->[0] : 'undef'
Because you're referring to two different variables (see above). -- |
From @Juerd
Oops. That's very stupid of me. However, these lines were only to make With the corrected program, the problem is still is:
That would be bad. After all, the dbh's refcount hasn't reached 0 yet. What use is a DESTROY method if parts of your object are destroyed Note also that it works correctly when the sub foo { $db } is removed. If you tie() $db->{dbi}, as with this block of code after the connect(): { package Blah; use Tie::Scalar; our @ISA = 'Tie::StdScalar'; A similar error message shows up: This should, as I understand it, never happen. I do believe this is a bug in Perl. Everything works correctly if $db Juerd |
From @iabyn(Just going through old perlbug tickets) Global cleanup is of the "if all else fails" variety; it simply goes In the case of sub foo { $db } this creates a closure, delaying the freeing of $db from end-of-file |
@iabyn - Status changed from 'open' to 'rejected' |
Migrated from rt.perl.org#18951 (status was 'rejected')
Searchable as RT18951$
The text was updated successfully, but these errors were encountered: