Matt Diephouse (via RT) wrote:
# New Ticket Created by Matt Diephouse
# Please include the string: [perl #37045]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/rt3/Ticket/Display.html?id=37045 >
In the key below, S15 shows up as "he", even though it is really "ll":
harmony:~/Projects/parrot mdiep$ cat test.pir
.sub main @MAIN
$P0 = new Hash
$S0 = "hello world"
$S1 = substr $S0, 2, 2
$S1 .= ""
$I0 = exists $P0[$S1]
end
.end
harmony:~/Projects/parrot mdiep$ parrot -tf test.pir
0 new P30, 51 - P30=PMCNULL,
3 set S30, "hello world" - ,
6 substr S15, S30, 2, 2 - , S30="hello world", ,
11 concat S15, "" - S15="ll",
14 exists I30, P30[S15="he"] - I30=0, P30=Hash=PMC
(0xe4e230),
18 end
Looks to me like it's a problem with the tracing, which should be fixed
by this patch.
There's similar code for constant string keys, but I think that these
will always be safely anchored at the string start.
Nick
Index: src/trace.c
===================================================================
--- src/trace.c (revision 9124)
+++ src/trace.c (working copy)
@@ -178,7 +178,7 @@
break;
case KEY_string_FLAG|KEY_register_FLAG:
s = REG_STR(PMC_int_val(key));
- escaped = PDB_escape(PObj_bufstart(s), s->strlen);
+ escaped = PDB_escape(s->strstart, s->strlen);
PIO_eprintf(interpreter, "S%vd=\"%s\"", PMC_int_val(key),
escaped ? escaped : "(null");
if (escaped)