----- Original Message -----
From: "chromatic (via RT)" <[EMAIL PROTECTED]>
Sent: Saturday, February 09, 2008 11:29 PM
Subject: [perl #50684] String Failures with -O2 (GCC 4.1.3, 32-bit x86
Linux)
I recompiled Parrot with the -march and -O2 flags, to see what kind of
speed
boosts we get from optimization (modest improvements in IMCC, about
20%
overall). Unfortunately, several tests failed with segfaults, due to
a
problem somewhere in string handling:
t/op/string.t
Failed test number(s): 71, 73
(gdb) run -G t/op/string_73.pasm
(gdb) bt
#0 0xb7ce5376 in string_length (interp_unused=0x804f008, s=0x0)
at src/string.c:746
#1 0xb7ce55e6 in string_ord (interp=0x804f008, s=0x0, idx=0)
at src/string.c:832
#2 0xb7cfa7bf in Parrot_ord_i_s_ic (cur_opcode=0x8256918,
interp=0x804f008)
at src/ops/string.ops:47
Looking at just this one case, we see that string_ord is called with a
NULL s argument, whereas the function header states that s is nonnull.
The GCC optimiser believes what it is told, and therefore discards the
test for s being not null, and calls string_length regardless.
string_length has also been told to expect a nonnull argument, and
behaves accordingly. I strongly suspect that most, if not all, the other
failures stem from the same logic.
There are two apparent solutions: check all notnull arguments before
calling the functions or remove the nonnull attribute where it is not
true.
Regards
Peter Gibbs