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

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

Ryan Voots
January 19, 2019 23:02
-Dusemymalloc and t/re/uniprops0{2,3}.t
Message ID:
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

but also the following, just being a single non-significant digit different
will work:

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,
         result[2] = Perl_strtod(s, &endp);

         /* If we created a copy, 'endp' is in terms of that.  Convert back
-         * 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;

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
just make sure to use the blead version of perl.

Ryan Voots Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About