Subject: | TxnScopeGuard dies if $@ contains object |
I have an application using a sqlite3 database. When putting a new
value into this database I somehow triggered the following error
message:
Show quoted text
-------------------- Begin error ---------------------------------------
Operation "ne": no method found,
left argument in overloaded package Text::Balanced::ErrorMsg,
right argument has no overloaded magic at /home_local/hmai/
perl5/perlbrew/perls/perl-5.14.2/lib/site_perl/5.14.2/DBIx/Class/
Storage/TxnScopeGuard.pm line 25.
at /home_local/hmai/perl5/perlbrew/perls/perl-5.14.2/lib/
site_perl/5.14.2/DBIx/Class/Storage/TxnScopeGuard.pm line 25
DBIx::Class::Storage::TxnScopeGuard::new
('DBIx::Class::Storage::TxnScopeGuard',
'DBIx::Class::Storage::DBI::SQLite=HASH(0x6aa2fe8)') called at /
home_local/hmai/perl5/perlbrew/perls/perl-5.14.2/lib/site_perl/5.14.2/
DBIx/Class/Storage.pm line 488
DBIx::Class::Storage::txn_scope_guard
('DBIx::Class::Storage::DBI::SQLite=HASH(0x6aa2fe8)') called at /
home_local/hmai/perl5/perlbrew/perls/perl-5.14.2/lib/site_perl/5.14.2/
DBIx/Class/Row.pm line 339
DBIx::Class::Row::insert
('Tapper::Schema::ReportsDB::Result::NotificationEvent=HASH(0x6...')
called at t/tapper-notification.t line 63
--------------------- End error -----------------------------------
I do not know what exactly triggered this but I do know what the issue
is. The relevant line in TxnScopeGuard checks whether $@ contains an
empty string. In fact it does contain a Text::Balanced::ErrorMsg
object. This object does overwrite stringification but that is not
triggered. The attached patch fixes this by triggering the
stringification.
Subject: | stringify_evalerror.patch |
diff -ru a/DBIx/Class/Storage/TxnScopeGuard.pm b/DBIx/Class/Storage/TxnScopeGuard.pm
--- a/DBIx/Class/Storage/TxnScopeGuard.pm 2012-02-14 11:36:38.463933111 +0100
+++ b/DBIx/Class/Storage/TxnScopeGuard.pm 2012-02-14 11:36:16.324211446 +0100
@@ -22,7 +22,7 @@
# we are starting with an already set $@ - in order for things to work we need to
# be able to recognize it upon destruction - store its weakref
# recording it before doing the txn_begin stuff
- if (defined $@ and $@ ne '') {
+ if (defined $@ and "$@" ne '') {
$guard->{existing_exception_ref} = (ref $@ ne '') ? $@ : \$@;
weaken $guard->{existing_exception_ref};
}