Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#401 can't display variables if any subroutines are present

open
Jan Ploski
Debugger (177)
7
2014-08-16
2007-05-31
Jack Tanner
No

Using Eclipse 3.2.2 on FC6. Start stepping through the code below, and when you step inside arf, the variable view changes to "An error occurred while dumping array content; contents of the Variables view may become invalid".

my $foo = 'bar';

arf($foo);

sub arf {
my $bar = shift;
print $bar;
}

(By the way, that error message is missing a period.)

Discussion

1 2 > >> (Page 1 of 2)
  • Jack Tanner
    Jack Tanner
    2007-05-31

    Logged In: YES
    user_id=661682
    Originator: YES

    I forgot to say that I'm using EPIC 0.6.5, and this used to work fine in earlier versions.

     
  • Jack Tanner
    Jack Tanner
    2007-06-01

    Logged In: YES
    user_id=661682
    Originator: YES

    This bug is worse than I thought. If your code calls a subroutine of your own, even if you skip over the subroutine, the debugger will terminate with an IOException. (Pop-up from PerlDebugJob, message "An IOException occurred while executing debugger command".)

    To reproduce, step through this code, and step over the call to arf().

    I see there were recent changes to the debugger, so this is probably related, and I'm reassigning accordingly. My apologies if that's incorrect.

    my $foo = 'bar';

    arf($foo);
    $foo = 'baz';

    sub arf {
    my $bar = shift;
    print $bar;
    }

     
  • Jack Tanner
    Jack Tanner
    2007-06-01

    • priority: 5 --> 7
    • assigned_to: stephan_ruehl --> jploski
    • summary: can't display variables in subroutine --> can't display variables if any subroutines are present
     
  • Jan Ploski
    Jan Ploski
    2007-06-02

    Logged In: YES
    user_id=86907
    Originator: NO

    You are right that there were significant changes to the debugger in 0.6.5. However, I cannot reproduce this bug on Debian. Maybe you could provide the contents of the debugger console?

     
  • Logged In: NO

    Duh! Sorry, I should've turned on the debugger console right away. This may be the culprit:

    Unmatched right curly bracket at (eval 48)[/usr/lib/perl5/5.8.8/perl5db.pl:628] line 5, at end of line
    syntax error at (eval 48)[/usr/lib/perl5/5.8.8/perl5db.pl:628] line 5, near ";
    }"

    Follow-up at https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=242249

     
  • Jan Ploski
    Jan Ploski
    2007-06-02

    Logged In: YES
    user_id=86907
    Originator: NO

    Given that you mention the right curly bracket thing, it may be related to a bug in perl5db.pl discussed in August 2006. Link to fix: http://sourceforge.net/forum/message.php?msg_id=3872285

     
  • Logged In: NO

    OK, I've upgraded to 0.6.6, and it seems like you're now shipping an internal perl5db.pl, so that cause should be out.

    See if you can reproduce the bug by stepping through this.

    my $foo = 'bar';

    my $ref = arf();
    print "$foo\n";

    sub arf {
    my %h = (
    arf => 1,
    scarf => 2
    );

    return \%h;
    }

     
  • Jack Tanner
    Jack Tanner
    2007-06-05

    Logged In: YES
    user_id=661682
    Originator: YES

    I thought I'd do something clever and modify the internal perl5db.pl, but it seems like it gets overwritten with every debug run. Where does the master perl5db.pl live that is used to overwrite?

     
  • Jan Ploski
    Jan Ploski
    2007-06-05

    Logged In: YES
    user_id=86907
    Originator: NO

    The master perl5db.pl is taken from your system (it is located by inspecting @INC - it likely resides somewhere in /usr/share/perl/5.8 or the like). Therefore, previous remarks about a possible bug in it remain valid. EPIC (unfortunately!) has to patch up perl5db.pl by inserting an invocation to epic_breakpoints.pm. This patching up is done on each launch.

     
  • Jack Tanner
    Jack Tanner
    2007-06-05

    Logged In: YES
    user_id=661682
    Originator: YES

    I made the change in the system perl5db.pl, it propagated to EPIC's copy, *but it still choked with the same error*.

     
  • Jan Ploski
    Jan Ploski
    2007-06-05

    A version of perl5db.pl to try out

     
    Attachments
  • Jan Ploski
    Jan Ploski
    2007-06-05

    Logged In: YES
    user_id=86907
    Originator: NO

    File Added: perl5db.pl.gz

     
  • Jan Ploski
    Jan Ploski
    2007-06-05

    Logged In: YES
    user_id=86907
    Originator: NO

    Just to make sure, try out the version I just attached (one from my system).

     
  • Jack Tanner
    Jack Tanner
    2007-06-05

    Logged In: YES
    user_id=661682
    Originator: YES

    The version you attached and the version I used to test differ only in whitespace. Does it really work for you if you step through this code? The bug seems to have to do with hashes.

    my $foo = 'bar';

    my $ref = arf(); ## Error after this step.
    print "$foo\n";

    sub arf {
    my %h = (
    arf => 1,
    scarf => 2
    );

    return \%h;
    }

     
  • Jan Ploski
    Jan Ploski
    2007-06-06

    Logged In: YES
    user_id=86907
    Originator: NO

    Yes, stepping through this code works flawlessly for me.

    I suppose you still have the "Unmatched right curly bracket" symptom. It would be a good idea to examine what string is being (unsuccessfully) evaluated in perl5db.pl and causes this symptom. Just hack perl5db.pl and print the string out to some file. The previously referenced bug had to do with perl5db.pl evaluating incomplete fragments of code from the input stream supplied by EPIC instead of the whole statements - insufficient buffering so to say.

    I also suspect there might be something strange in your environment variables. You might try debugging the same script with an artificial/empty environment (use the "Environment" tab in the launch configuration to override the default environment).

     
  • Peter Grape
    Peter Grape
    2007-06-19

    Logged In: YES
    user_id=1821949
    Originator: NO

    Hi, all

    I have the same problem, here is the stacktrace from Eclipse error log:

    java.lang.StringIndexOutOfBoundsException: String index out of range: 113
    at java.lang.String.charAt(Unknown Source)
    at org.epic.debug.db.DumpedEntityReader.token(DumpedEntityReader.java:46)
    at org.epic.debug.db.DumpedEntityReader.nextEntity(DumpedEntityReader.java:33)
    at org.epic.debug.db.HashValue.parseHashContent(HashValue.java:49)
    at org.epic.debug.db.HashValue.<init>(HashValue.java:25)
    at org.epic.debug.db.PerlVariable.getValue(PerlVariable.java:118)
    at org.eclipse.debug.internal.ui.elements.adapters.VariableLabelAdapter.getLabels(VariableLabelAdapter.java:43)
    at org.eclipse.debug.internal.ui.viewers.provisional.AsynchronousLabelAdapter.computeLabels(AsynchronousLabelAdapter.java:94)
    at org.eclipse.debug.internal.ui.elements.adapters.AsynchronousDebugLabelAdapter.computeLabels(AsynchronousDebugLabelAdapter.java:66)
    at org.eclipse.debug.internal.ui.viewers.provisional.AsynchronousLabelAdapter$2.run(AsynchronousLabelAdapter.java:51)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)

    I am using the 0.6.9 version of EPIC, Eclipse 3.2.2, Perl 5.8.8 from ActiveState.

    /Peter

     
  • Jan Ploski
    Jan Ploski
    2007-06-19

    Logged In: YES
    user_id=86907
    Originator: NO

    Peter, can you also post the complete output from the debug console when this exception occurs? Enable the debug console in EPIC Preferences. Then, start a debug session and click on the "perl -d" item in the Debug view for the debug console's content to appear in the Console view.

    Basically, the exception indicates that EPIC is unable to parse whatever perl5db.pl has produced. Clearly, it could be either a problem with EPIC or with perl5db.pl.

     
  • Peter Grape
    Peter Grape
    2007-06-20

    Logged In: YES
    user_id=1821949
    Originator: NO

    Here is part of the dump when the variables display crashes for me w. the eclipse stacktrace i sent yesterday.

    ;{
    do 'dumpvar_epic.pm' unless defined &dumpvar_epic::dump_lexical_vars;

    my $offset = 0;
    my $varexpr = <<'EOT';
    \$main::cgi
    EOT
    my $subref = \&dumpvar_epic::dump_hash_expr;
    my $savout = select($DB::OUT);
    $subref->($offset, $varexpr);
    select($savout);
    };

    Not a HASH reference at C:/Software/eclipse/workspace/.metadata/.plugins/org.epic.debug/dumpvar_epic.pm line 206.

    DB<47> ;{
    do 'dumpvar_epic.pm' unless defined &dumpvar_epic::dump_lexical_vars;

    my $offset = 0;
    my $varexpr = <<'EOT';
    \$main::cgi
    EOT
    my $subref = \&dumpvar_epic::dump_hash_expr;
    my $savout = select($DB::OUT);
    $subref->($offset, $varexpr);
    select($savout);
    };

    Not a HASH reference at C:/Software/eclipse/workspace/.metadata/.plugins/org.epic.debug/dumpvar_epic.pm line 206.

    DB<48>

    Hope this helps, if you want more , I can send you the whole stacktrace, but I do not want to place it here since it might contain private info.

    /Peter

     
  • Peter Grape
    Peter Grape
    2007-06-20

    Logged In: YES
    user_id=1821949
    Originator: NO

    I had a quick browse through the console and I found a line which says "0||" I do not know if this is of any intrest....
    ......... snip ................

    4|$min|1|1|17|SCALAR(0x215bff0)|4|'48'|1|4
    6|$month|1|1|17|SCALAR(0x215bf9c)|4|'06'|1|4
    31|%payment_period_contract_labels|1|1|15|HASH(0x22cf670)|3|...|1|3
    22|%payment_period_labels|1|1|15|HASH(0x22cf568)|3|...|1|3
    4|$sec|1|1|17|SCALAR(0x215c008)|4|'25'|1|4
    18|FileHandle(stderr)|1|1|17|SCALAR(0x32620a4)|11|'fileno(2)'|2|11
    17|FileHandle(stdin)|1|1|17|SCALAR(0x3201a9c)|11|'fileno(0)'|2|11
    18|FileHandle(stdout)|1|1|17|SCALAR(0x32620bc)|11|'fileno(1)'|2|11
    12|$stopForward|1|1|17|SCALAR(0x2198fcc)|3|'0'|1|3
    9|%userinfo|1|1|15|HASH(0x214ca6c)|3|...|1|3
    5|$year|1|1|17|SCALAR(0x215bf3c)|6|'2007'|1|6
    2|$||1|1|17|SCALAR(0x18bae78)|3|'1'|1|3
    2|$~|1|1|17|SCALAR(0x18bb94c)|6|'GEN0'|1|6

    DB<63> ;{
    do 'dumpvar_epic.pm' unless defined &dumpvar_epic::dump_lexical_vars;

    my $offset = 3;
    my $savout = select($DB::OUT);
    dumpvar_epic::dump_lexical_vars($offset);
    select($savout);
    };

    17|$ejKreditprovning|1|1|17|SCALAR(0x2dd0db4)|3|'0'|1|3
    12|$errand_base|1|1|17|SCALAR(0x2dd0e08)|5|undef|1|5
    10|$errand_id|1|1|17|SCALAR(0x2dd0de4)|5|undef|1|5
    17|$preview_contract|1|1|17|SCALAR(0x2e4ebd8)|5|undef|1|5
    13|$preview_flag|1|1|17|SCALAR(0x2df1f6c)|3|'1'|1|3
    25|$reseller_reseller_number|1|1|17|SCALAR(0x2cffe68)|7|'30700'|1|7
    7|$status|1|1|17|SCALAR(0x2cffde4)|3|'1'|1|3
    12|$status_text|1|1|17|SCALAR(0x2cffe08)|2|''|1|2
    6|%param|1|1|15|HASH(0x2dd0cb8)|3|...|1|3
    12|@param_names|1|1|16|ARRAY(0x2db2e8c)|3|...|1|3
    8|@saljare|1|1|16|ARRAY(0x2cffea4)|3|...|1|3

    DB<64> ;{
    do 'dumpvar_epic.pm' unless defined &dumpvar_epic::dump_lexical_vars;

    my $offset = 3;
    my $varexpr = <<'EOT';
    \%main::AfBksInfoHoA
    EOT
    my $subref = \&dumpvar_epic::dump_hash_expr;
    my $savout = select($DB::OUT);
    $subref->($offset, $varexpr);
    select($savout);
    };

    6|adress|1|2|14|REF(0x2c8a3f4)|16|ARRAY(0x2c8a358)|3|...|1|3
    9|hd_finans|1|2|14|REF(0x2ccc91c)|16|ARRAY(0x2c8a5d4)|3|...|1|3
    4|namn|1|2|14|REF(0x1d60e38)|16|ARRAY(0x2c8a43c)|3|...|1|3
    5|orgnr|1|2|14|REF(0x2c5dfdc)|16|ARRAY(0x2c8a4e4)|3|...|1|3
    3|ort|1|2|14|REF(0x2c8a448)|16|ARRAY(0x2c8a22c)|3|...|1|3
    6|postnr|1|2|14|REF(0x2c89ce8)|16|ARRAY(0x2c89cb8)|3|...|1|3
    7|telefon|1|2|14|REF(0x2c8a124)|16|ARRAY(0x2c8a3b8)|3|...|1|3

    DB<65> ;{
    do 'dumpvar_epic.pm' unless defined &dumpvar_epic::dump_lexical_vars;

    my $offset = 3;
    my $varexpr = <<'EOT';
    \%main::FIELDS
    EOT
    my $subref = \&dumpvar_epic::dump_hash_expr;
    my $savout = select($DB::OUT);
    $subref->($offset, $varexpr);
    select($savout);
    };

    7|default|1|2|14|REF(0x2cccfb8)|16|ARRAY(0x2ccca00)|3|...|1|3
    5|page1|1|2|14|REF(0x2cccfc4)|16|ARRAY(0x2c5dfac)|3|...|1|3
    6|page14|1|2|14|REF(0x2cccff4)|16|ARRAY(0x2c8a580)|3|...|1|3
    5|page2|1|2|14|REF(0x2cccfd0)|16|ARRAY(0x2c8a034)|3|...|1|3
    6|page20|1|2|14|REF(0x2ccd000)|16|ARRAY(0x2cccfa0)|3|...|1|3
    5|page3|1|2|14|REF(0x2cccfdc)|16|ARRAY(0x2c5e33c)|3|...|1|3
    5|page4|1|2|14|REF(0x2cccfe8)|16|ARRAY(0x2ccc9e8)|3|...|1|3

    DB<66> ;{
    do 'dumpvar_epic.pm' unless defined &dumpvar_epic::dump_lexical_vars;

    my $offset = 3;
    my $varexpr = <<'EOT';
    \%main::FLAG
    EOT
    my $subref = \&dumpvar_epic::dump_hash_expr;
    my $savout = select($DB::OUT);
    $subref->($offset, $varexpr);
    select($savout);
    };

    0||1|1|17|SCALAR(0x22f1134)|5|'Nej'|1|5
    1|0|1|1|17|SCALAR(0x1c7e2e8)|5|'Nej'|1|5
    1|1|1|1|17|SCALAR(0x1c7e2f4)|4|'Ja'|1|4

    DB<67> ;{
    do 'dumpvar_epic.pm' unless defined &dumpvar_epic::dump_lexical_vars;

    my $offset = 3;
    my $varexpr = <<'EOT';
    \%main::FOCUS
    EOT
    my $subref = \&dumpvar_epic::dump_hash_expr;
    my $savout = select($DB::OUT);
    $subref->($offset, $varexpr);
    select($savout);
    };

    5|page1|1|1|17|SCALAR(0x2ccd054)|14|'onPageLoad()'|2|14
    5|page2|1|1|17|SCALAR(0x2ccd060)|14|'onPageLoad()'|2|14
    5|page3|1|1|17|SCALAR(0x2ccd06c)|14|'onPageLoad()'|2|14
    5|page4|1|1|17|SCALAR(0x2ccd0d8)|14|'onPageLoad()'|2|14
    5|page5|1|1|17|SCALAR(0x2ccd0e4)|14|'onPageLoad()'|2|14
    5|page6|1|1|17|SCALAR(0x2ccd0f0)|9|'init();'|1|9
    5|page8|1|1|17|SCALAR(0x2ccd0fc)|38|'document.forms[0].sokdatum.select();'|2|38
    5|page9|1|1|17|SCALAR(0x2ccd108)|14|'onPageLoad()'|2|14

    ......... snip ................

    /Peter

     
  • Jack Tanner
    Jack Tanner
    2007-06-25

    trace from hacked perl5db.pl

     
    Attachments
  • Jack Tanner
    Jack Tanner
    2007-06-25

    Logged In: YES
    user_id=661682
    Originator: YES

    The bug still exists with EPIC 0.6.10 under Eclipse 3.2.2 on Fedora 7. I attach a trace from a hacked perl5db.pl. The hack itself was to add this code at perl5db.pl line 622

    open (my $debug_fh, '>>', '/tmp/debug-log.txt');
    print $debug_fh "USERCONTEXT:\n$usercontext\n";
    print $debug_fh "EVALARG:\n$evalarg\n\n";
    close $debug_fh;

    File Added: debug-log.txt

     
  • Jan Ploski
    Jan Ploski
    2007-06-25

    Logged In: YES
    user_id=86907
    Originator: NO

    I think the problem lies in this loop located in perl5db.pl's sub readline:

    do {
    $IN->recv( $buf = '', 2048 ); # XXX "what's wrong with sysread?"
    # XXX Don't know. You tell me.
    } while length $buf and ($stuff .= $buf) !~ /\n/;

    It is supposed to "receive anything there is to receive"... However, it does not in your case receive the whole command string from EPIC and hence the subsequent eval of an incomplete block then causes errors. I see no way of fixing this loop to always reliably read the whole input from EPIC in principle - there is no terminator token which EPIC sends to indicate that it's done. Anyway, it is strange that the recv call returns after reading some 200 bytes in your case. The send and receive buffers for TCP sockets should be much larger than that.

    I'm attaching a simple script check_tcpbuf.pl which you can run to find out the size of the default TCP socket send/receive buffers on your system. When you run it, it will first print out the buffer sizes for a server socket, then it will start listening for a TCP connection on localhost:5001 (which you can establish using telnet or netcat), finally it will print out the buffer sizes for the client connection. For example, my system reports SO_RCVBUF=87380 and SO_SNDBUF=16384, which is more than necessary to accomodate the longest EPIC debugger command without splitting it into pieces on receive.

     
  • Jan Ploski
    Jan Ploski
    2007-06-25

    Script to find out SO_SNDBUF, SO_RCVBUF

     
    Attachments
  • Jan Ploski
    Jan Ploski
    2007-06-25

    Logged In: YES
    user_id=86907
    Originator: NO

    File Added: check_tcpbuf.pl

     
1 2 > >> (Page 1 of 2)