develooper Front page | perl.perl5.porters | Postings from January 2019

-Dusemymalloc and t/re/uniprops0{2,3}.t

From:
Ryan Voots
Date:
January 19, 2019 23:02
Subject:
-Dusemymalloc and t/re/uniprops0{2,3}.t
Message ID:
CA+sVJX=NGmXf2em7+EH+190tbY7qq4GOPQkovFWOtmy=tvig-A@mail.gmail.com
This was all discovered on IRC over the past few days and Karl was the one
to find the actual bug and fix for it.  I'm emailing p5p so that others
will know how this bug got found and fixed.

The bug:
A perl that's built with -Dusemymalloc results in t/re/uniprops0{2,3}.t
failing a few tests, all similar to the following:

From the tests, this specifically will fail to compile
qr/\p{Nv=8.000000000000000e+05}/

but also the following, just being a single non-significant digit different
will work:
qr/\p{Nv=8.000000000000000e+5}}/
qr/\p{Nv=8.00000000000000e+05}/
qr/\p{Nv=8.000000000000000e+005}/
qr/\p{Nv=8.0000000000000000e+05}/

that regex means "match any unicode character who has a numeric value
meaning 800,000" and is what's being tested in the generated test files.

The fix:

Karl made a fix for this

diff --git a/numeric.c b/numeric.c
index e5e08cb241..3fc11234c3 100644
--- a/numeric.c
+++ b/numeric.c
@@ -1463,8 +1463,10 @@ Perl_my_atof3(pTHX_ const char* orig, NV* value,
STRLEN len)
         result[2] = Perl_strtod(s, &endp);

         /* If we created a copy, 'endp' is in terms of that.  Convert back
to
-         * the original */
+         * the original.  We also need to do the same conversion with s for
+         * the same reason. */
         if (copy) {
+            s = (s - copy) + (char *) orig;
             endp = (endp - copy) + (char *) orig;
             Safefree(copy);
         }

He had it on the branch smoke-me/khw-private_use, I altered it for the
email here slightly to adjust the comment appropriately also.

Further background:
A user on IRC was wanting to play with $^M and catch a stack overflow in
his code and wanted help to get a perl setup properly to actually use the
emergency memory pool.  I decided to help to test the feature because it
sounded neat and discovered that at least the 5.29 branch would build but
not pass tests when -DPERL_EMERGENCY_SBRK and -Dusemymalloc were set.  This
can now be played with on irc through perlbot's eval or on https://perl.bot/
just make sure to use the blead version of perl.

Ryan Voots



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About