Hi Andrew, From: Andrew Hewus Fresh <and...@afresh1.com> Date: Wed, 24 Mar 2021 19:02:54 -0700
> On Thu, Mar 25, 2021 at 09:50:17AM +0900, Masato Asou wrote: >> Because, Perl 5.32.1 has changed the way hexadecimal string are >> handled as below: >> >> Perl 5.30.3: "0x1234" + 0x1000 -> 0x2234 >> Perl 5.32.1: "0x1234" + 0x1000 -> 0x1000 > > Interestingly, this bug only existed in perl v5.30, so an unfortunate > accident of timing on the creation of this patch. > > $ perldoc perl5320delta | grep -B4 134230 > • Perl no longer treats strings starting with "0x" or "0b" as hex or > binary numbers respectively when converting a string to a number. > This reverts a change in behaviour inadvertently introduced in perl > 5.30.0 intended to improve precision when converting a string to a > floating point number. [perl #134230 > <https://rt.perl.org/Ticket/Display.html?id=134230>] > > >> Perl 5.32.1 does not consider anything after 'x' to be a number, but >> only the first '0' is consider to be a number. > > Neither does any other perl 5, only perl 5.30 accidentally did. > > Perl simplistically looks for leading ascii digits in in a string to > "convert" from a string to a number, and an empty string is treated as > 0. Just because the unquoted version would be treated differently > isn't supposed to matter. > > $ perl -E 'say "$_: " . ( "${_}x123" + 0 ) for qw< 0 1 987 a z >' > 0: 0 > 1: 1 > 987: 987 > a: 0 > z: 0 Thank you for your detailed explanation. >> I made the following patch. >> >> ok? comments? >> -- >> ASOU Masato >> >> Index: devel/valgrind/patches/patch-coregrind_link_tool_exe_openbsd_in >> =================================================================== >> RCS file: >> /cvs/ports/devel/valgrind/patches/patch-coregrind_link_tool_exe_openbsd_in,v >> retrieving revision 1.5 >> diff -u -p -r1.5 patch-coregrind_link_tool_exe_openbsd_in >> --- devel/valgrind/patches/patch-coregrind_link_tool_exe_openbsd_in 5 >> Oct 2020 01:45:58 -0000 1.5 >> +++ devel/valgrind/patches/patch-coregrind_link_tool_exe_openbsd_in 25 >> Mar 2021 00:27:19 -0000 >> @@ -10,7 +10,7 @@ >> +# strip command rewrite offset and align in ELF file. Therefor, when >> valgrind >> +# launch memcheck-amd64-openbsd, an Abort trap occurs in the execvp() >> system >> +# call. >> -+my $cmd = sprintf "$cc -static -nopie -Wl,--strip-all -Wl,-Ttext=0x%x", >> "$ala + 0x1000"; >> ++my $cmd = sprintf "$cc -static -nopie -Wl,--strip-all -Wl,-Ttext=0x%x", >> hex($ala) + 0x1000; > > This seems to give consistent results on all the perl I have from 5.8 > through 5.33.7. > > perl -e 'my $ala = "0x1234"; print(( $ala + 0x100 ), "\n"); print(( hex($ala) > + 0x100 ), "\n")' > > OK afresh1@ commited. -- ASOU Masato