Description
I am checking breakpoints in my debugger like this:
# Returns TRUE if we can set trap for $file:line
sub DB::can_break {
my( $file, $line ) = @_;
($file, $line) = split ':', $file
unless defined $line;
$file = DB::file( $file );
return unless defined $file;
no strict 'refs';
return $line >= 0 && $line <= $#{ $::{"_<$file"} }
&& ${ $::{"_<$file"} }[ $line ] != 0; # <<< LINE 562
# http://perldoc.perl.org/perldebguts.html#Debugger-Internals
# Values in this array are magical in numeric context:
# they compare equal to zero only if the line is not breakable.
}
And I god this error message during debugging SQL::Translator:
(eval 481)[/home/kes/work/projects/github-forks/sql-translator/local/lib/perl5/Class/Method/Modifiers.pm:148]
Argument "package SQL::Translator;\n" isn't numeric in numeric ne (!=) at /home/kes/work/projects/github-forks/sql-translator/local/lib/perl5/DB/Utils.pm line 562, <STDIN> line 35.
It looks like values are not always magical in numeric context.
Steps to Reproduce
Too complex =(
Expected behavior
As documented the values at the array should be magical
In my debugger I am checking the line is breakable or not via ${ $::{"_<$file"} }[ $line ] != 0;
If yes I print 'x', if not I do not print 'x'. Here you can see that lines 40-43, 45-50 are not magical for some reason:
(eval 504)[/home/kes/work/projects/github-forks/sql-translator/local/lib/perl5/Sub/Quote.pm:3] x26: return $invoker->new(@_); x27: } elsif ($INC{"Moose.pm"} and my $meta = Class::MOP::get_metaclass_by_name($class)) { x28: return $meta->new_object( 29: $class->can("BUILDARGS") ? $class->BUILDARGS(@_) 30: : $class->Moo::Object::BUILDARGS(@_) 31: ); 32: } 33: } 34: my $args = scalar @_ == 1 35: ? CORE::ref $_[0] eq 'HASH' >>36: ? { %{ $_[0] } } 37: : Carp::croak("Single parameters to new() must be a HASH ref" 38: . " data => ". $_[0]) 39: : @_ % 2 Argument " ? Carp::croak("The new() method for $class expec..." isn't numeric in numeric ne (!=) at /home/kes/work/projects/github-forks/sql-translator/local/lib/perl5/DB/Utils.pm line 562, <STDIN> line 32. 40: ? Carp::croak("The new() method for $class expects a hash reference or a" Argument " . " key/value list. You passed an odd number..." isn't numeric in numeric ne (!=) at /home/kes/work/projects/github-forks/sql-translator/local/lib/perl5/DB/Utils.pm line 562, <STDIN> line 32. 41: . " key/value list. You passed an odd number of arguments") Argument " : {@_}\n" isn't numeric in numeric ne (!=) at /home/kes/work/projects/github-forks/sql-translator/local/lib/perl5/DB/Utils.pm line 562, <STDIN> line 32. 42: : {@_} Argument " ;\n" isn't numeric in numeric ne (!=) at /home/kes/work/projects/github-forks/sql-translator/local/lib/perl5/DB/Utils.pm line 562, <STDIN> line 32. 43: ; x44: my $new = bless({}, $class);; Argument "(exists $args->{"add_comments"} and ($new->{"add_comment..." isn't numeric in numeric ne (!=) at /home/kes/work/projects/github-forks/sql-translator/local/lib/perl5/DB/Utils.pm line 562, <STDIN> line 32. 45: (exists $args->{"add_comments"} and ($new->{"add_comments"} = $args->{"add_comments"})), Argument "(exists $args->{"add_drop_table"} and ($new->{"add_drop_..." isn't numeric in numeric ne (!=) at /home/kes/work/projects/github-forks/sql-translator/local/lib/perl5/DB/Utils.pm line 562, <STDIN> line 32. 46: (exists $args->{"add_drop_table"} and ($new->{"add_drop_table"} = $args->{"add_drop_table"})), Argument "(exists $args->{"escape_char"} and ($new->{"escape_char"..." isn't numeric in numeric ne (!=) at /home/kes/work/projects/github-forks/sql-translator/local/lib/perl5/DB/Utils.pm line 562, <STDIN> line 32. 47: (exists $args->{"escape_char"} and ($new->{"escape_char"} = $args->{"escape_char"})), Argument "(exists $args->{"numeric_types"} and ($new->{"numeric_ty..." isn't numeric in numeric ne (!=) at /home/kes/work/projects/github-forks/sql-translator/local/lib/perl5/DB/Utils.pm line 562, <STDIN> line 32. 48: (exists $args->{"numeric_types"} and ($new->{"numeric_types"} = $args->{"numeric_types"})), Argument "(exists $args->{"sizeless_types"} and ($new->{"sizeless_..." isn't numeric in numeric ne (!=) at /home/kes/work/projects/github-forks/sql-translator/local/lib/perl5/DB/Utils.pm line 562, <STDIN> line 32. 49: (exists $args->{"sizeless_types"} and ($new->{"sizeless_types"} = $args->{"sizeless_types"})), Argument "(exists $args->{"type_map"} and ($new->{"type_map"} = $a..." isn't numeric in numeric ne (!=) at /home/kes/work/projects/github-forks/sql-translator/local/lib/perl5/DB/Utils.pm line 562, <STDIN> line 32. 50: (exists $args->{"type_map"} and ($new->{"type_map"} = $args->{"type_map"})), x51: (exists $args->{"unquoted_defaults"} and ($new->{"unquoted_defaults"} = $args->{"unquoted_defaults"})), Argument " return $new;\n" isn't numeric in numeric ne (!=) at /home/kes/work/projects/github-forks/sql-translator/local/lib/perl5/DB/Utils.pm line 562, <STDIN> line 32. 52: return $new; Argument " }\n" isn't numeric in numeric ne (!=) at /home/kes/work/projects/github-forks/sql-translator/local/lib/perl5/DB/Utils.pm line 562, <STDIN> line 32. 53: } 54: $$_UNQUOTED = \&new; Argument "}\n" isn't numeric in numeric ne (!=) at /home/kes/work/projects/github-forks/sql-translator/local/lib/perl5/DB/Utils.pm line 562, <STDIN> line 32. 55: } 56: 1;
Probably this is due internals of Sub/Quote.pm:3
.
TL;DR; This does not belongs directly the case reported at this issue. But it could be interesting to know it because perl internal variables behaves strange for Sub::Quote
module.
File '(eval 712)[local/lib/perl5/Sub/Quote.pm:3]' is not compiled yet
. It is seldom, but if I got it, it is 100% reproducible.# Returns TRUE if $filename was compiled/evaled
# The file is evaled if it looks like (eval 34)
# But this may be changed by #file:line. See ??? for info
sub DB::file {
my $filename = shift // DB::state( 'file' );
$filename =~ s/^_<//;
# NOTICE differences:
# https://stackoverflow.com/q/56273829/4632019
# https://stackoverflow.com/q/56270222/4632019
# https://stackoverflow.com/q/56260910/4632019
# https://stackoverflow.com/q/56273425/4632019
no strict 'refs';
unless( exists ${ 'main::' }{ "_<$filename" } ) {
DB::warn "File '$filename' is not compiled yet"; # <<<Error comes from here
return;
}
return ${ $::{"_<$filename"} }
}
I do not expect that second error message when I step over the line, because it happens only in the certain cases. And if I do not trigger that case I can step over
that line of code at debugger.
How this code looks like:
Code:
19: # NOTICE: If I run the next code in debugger and then run "n" it fails with the error:
20: # File '(eval 712)[local/lib/perl5/Sub/Quote.pm:3]' is not compiled yet
21: # Can't use an undefined value as an ARRAY reference at local/lib/perl5/DB/Hooks.pm line 546
22: # Beware: the leeding space is important. Without it the code works well.
23: # DBG> A::FormData::process { Email => {} }
24: # DBG>n
>>25: db_clear();
26:
x27: $got = A::FormData::process { Email => {} };
x28: $expect = eval data_section 'main', 'email';
29:
x30: like $got, $expect, "Email";
31:
32: # <<
x33: D::db->txn_rollback;
x34: done_testing();
35:
36:
37: __DATA__
DBG> A::FormData::process { Email => {} }
{
Email => {
comment => undef,
company_id => 14,
email => mt1@example.com,
id => 6,
type => undef,
},
}
DBG>n
File '(eval 712)[local/lib/perl5/Sub/Quote.pm:3]' is not compiled yet
File '(eval 712)[local/lib/perl5/Sub/Quote.pm:3]' is not compiled yet
So here above the error is not compiled yet
happens only if I run A::FormData::process { Email => {} }
. If I do not run that code, then everything works fine. A::FormData::process
do interaction with many tables in database via DBIx::Class
. So it is not clear what happens there inside. Probably there occurs second call to Sub/Quote.pm
which makes conflict later.
Summary of my perl5 (revision 5 version 41 subversion 2) configuration:
Platform:
osname=linux
osvers=6.5.0-1027-oem
archname=x86_64-linux
uname='linux work 6.5.0-1027-oem #28-ubuntu smp preempt_dynamic thu jul 25 13:32:46 utc 2024 x86_64 x86_64 x86_64 gnulinux '
config_args='-de -Dprefix=/home/kes/perl5/perlbrew/perls/perl-5.41.2 -Dusedevel -Aeval:scriptdir=/home/kes/perl5/perlbrew/perls/perl-5.41.2/bin'
hint=recommended
useposix=true
d_sigaction=define
useithreads=undef
usemultiplicity=undef
use64bitint=define
use64bitall=define
uselongdouble=undef
usemymalloc=n
default_inc_excludes_dot=define
Compiler:
cc='cc'
ccflags ='-fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
optimize='-O2'
cppflags='-fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
ccversion=''
gccversion='13.1.0'
gccosandvers=''
intsize=4
longsize=8
ptrsize=8
doublesize=8
byteorder=12345678
doublekind=3
d_longlong=define
longlongsize=8
d_longdbl=define
longdblsize=16
longdblkind=3
ivtype='long'
ivsize=8
nvtype='double'
nvsize=8
Off_t='off_t'
lseeksize=8
alignbytes=8
prototype=define
Linker and Libraries:
ld='cc'
ldflags =' -fstack-protector-strong -L/usr/local/lib'
libpth=/usr/local/lib /usr/lib/x86_64-linux-gnu /usr/lib /usr/lib64
libs=-lpthread -ldl -lm -lcrypt -lutil -lc
perllibs=-lpthread -ldl -lm -lcrypt -lutil -lc
libc=/lib/x86_64-linux-gnu/libc.so.6
so=so
useshrplib=false
libperl=libperl.a
gnulibc_version='2.35'
Dynamic Linking:
dlsrc=dl_dlopen.xs
dlext=so
d_dlsymun=undef
ccdlflags='-Wl,-E'
cccdlflags='-fPIC'
lddlflags='-shared -O2 -L/usr/local/lib -fstack-protector-strong'
Characteristics of this binary (from libperl):
Compile-time options:
HAS_LONG_DOUBLE
HAS_STRTOLD
HAS_TIMES
PERLIO_LAYERS
PERL_COPY_ON_WRITE
PERL_DONT_CREATE_GVSV
PERL_HASH_FUNC_SIPHASH13
PERL_HASH_USE_SBOX32
PERL_MALLOC_WRAP
PERL_OP_PARENT
PERL_PRESERVE_IVUV
PERL_USE_DEVEL
PERL_USE_SAFE_PUTENV
USE_64_BIT_ALL
USE_64_BIT_INT
USE_LARGE_FILES
USE_LOCALE
USE_LOCALE_COLLATE
USE_LOCALE_CTYPE
USE_LOCALE_NUMERIC
USE_LOCALE_TIME
USE_PERLIO
USE_PERL_ATOF
Built under linux
Compiled at Aug 17 2024 19:35:18
%ENV:
PERLBREW="command perlbrew"
PERLBREW_HOME="/home/kes/.perlbrew"
PERLBREW_MANPATH="/home/kes/perl5/perlbrew/perls/perl-5.41.2/man"
PERLBREW_PATH="/home/kes/perl5/perlbrew/bin:/home/kes/perl5/perlbrew/perls/perl-5.41.2/bin"
PERLBREW_PERL="perl-5.41.2"
PERLBREW_ROOT="/home/kes/perl5/perlbrew"
PERLBREW_SHELLRC_VERSION="0.98"
PERLBREW_VERSION="0.98"
@INC:
/home/kes/perl5/perlbrew/perls/perl-5.41.2/lib/site_perl/5.41.2/x86_64-linux
/home/kes/perl5/perlbrew/perls/perl-5.41.2/lib/site_perl/5.41.2
/home/kes/perl5/perlbrew/perls/perl-5.41.2/lib/5.41.2/x86_64-linux
/home/kes/perl5/perlbrew/perls/perl-5.41.2/lib/5.41.2
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4