New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bleadperl 9de15fe breaks MATISSE/Perl-Metrics-Simple-0.15.tar.gz #10663
Comments
From @andkThe fail is revealing a glibc disgruntlement of the sort below. Let me *** glibc detected *** /home/src/perl/repoperls/installed-perls/perl/v5.13.5-74-g9de15fe/bin/perl: free(): invalid pointer: 0x00000000012c5ba0 *** git bisect: commit 9de15fe Add /d, /l, /u (infixed) regex modifiers perl -V: Summary of my perl5 (revision 5 version 13 subversion 5) configuration: Characteristics of this binary (from libperl): -- |
From @khwilliamson(Andreas J. Koenig) (via RT) wrote:
I'll look at this when I get back on tuesday afternoon GMT-6 |
The RT System itself - Status changed from 'new' to 'open' |
From @khwilliamsonI'm investigating this problem. I can't reproduce this with the test (Andreas J. Koenig) (via RT) wrote:
|
From @andk
> I'm investigating this problem. I can't reproduce this with the test No, it was with the test suite. -- |
From @khwilliamsonPatch attached. The root cause is that I forgot to properly account the extra space |
From @khwilliamson0001--perl-78040-regcomp.c-malloc-enough-space.patchFrom c0b0ad942f29d37f997db5a93e007e8c0fa7af30 Mon Sep 17 00:00:00 2001
From: Karl Williamson <public@khwilliamson.com>
Date: Wed, 29 Sep 2010 13:50:52 -0600
Subject: [PATCH] [perl #78040] regcomp.c: malloc enough space
Commit 9de15fec376a8ff90a38fad0ff322c72c2995765 introduced /u, /d, and
/l regex modifiers. Unfortunately, I forgot to adequately account for
them in the space required for the stringification of the regex.
This patch figures out separately if the caret is needed, and if one of
these charset modifiers is needed, and allocates space accordingly.
I could not figure out a simple test case for this fix. valgrind
prior to this will show errors, and after this doesn't.
---
regcomp.c | 33 +++++++++++++++++++++++----------
1 files changed, 23 insertions(+), 10 deletions(-)
diff --git a/regcomp.c b/regcomp.c
index bcdc65f..44f75b7 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -4425,33 +4425,46 @@ Perl_re_compile(pTHX_ SV * const pattern, U32 pm_flags)
r->extflags = pm_flags;
{
bool has_p = ((r->extflags & RXf_PMf_KEEPCOPY) == RXf_PMf_KEEPCOPY);
- bool has_minus = ((r->extflags & RXf_PMf_STD_PMMOD) != RXf_PMf_STD_PMMOD);
+ bool has_charset = (r->extflags & (RXf_PMf_LOCALE|RXf_PMf_UNICODE));
+
+ /* The caret is output if there are any defaults: if not all the STD
+ * flags are set, or if no character set specifier is needed */
+ bool has_default =
+ (((r->extflags & RXf_PMf_STD_PMMOD) != RXf_PMf_STD_PMMOD)
+ || ! has_charset);
bool has_runon = ((RExC_seen & REG_SEEN_RUN_ON_COMMENT)==REG_SEEN_RUN_ON_COMMENT);
U16 reganch = (U16)((r->extflags & RXf_PMf_STD_PMMOD)
>> RXf_PMf_STD_PMMOD_SHIFT);
const char *fptr = STD_PAT_MODS; /*"msix"*/
char *p;
/* Allocate for the worst case, which is all the std flags are turned
- * on, but this means no caret. We never output a minus, as all those
- * are defaults, so are covered by the caret */
+ * on. If more precision is desired, we could do a population count of
+ * the flags set. This could be done with a small lookup table, or by
+ * shifting, masking and adding, or even, when available, assembly
+ * language for a machine-language population count.
+ * We never output a minus, as all those are defaults, so are
+ * covered by the caret */
const STRLEN wraplen = plen + has_p + has_runon
+ + has_default /* If needs a caret */
+ + has_charset /* If needs a character set specifier */
+ (sizeof(STD_PAT_MODS) - 1)
+ (sizeof("(?:)") - 1);
- p = sv_grow(MUTABLE_SV(rx), wraplen + 1);
+ p = sv_grow(MUTABLE_SV(rx), wraplen + 1); /* +1 for the ending NUL */
SvPOK_on(rx);
SvFLAGS(rx) |= SvUTF8(pattern);
*p++='('; *p++='?';
/* If a default, cover it using the caret */
- if (has_minus || (r->extflags & ~(RXf_PMf_LOCALE|RXf_PMf_UNICODE))) {
+ if (has_default) {
*p++= DEFAULT_PAT_MOD;
}
- if (r->extflags & RXf_PMf_LOCALE) {
- *p++ = LOCALE_PAT_MOD;
- }
- else if (r->extflags & RXf_PMf_UNICODE) {
- *p++ = UNICODE_PAT_MOD;
+ if (has_charset) {
+ if (r->extflags & RXf_PMf_LOCALE) {
+ *p++ = LOCALE_PAT_MOD;
+ } else {
+ *p++ = UNICODE_PAT_MOD;
+ }
}
if (has_p)
*p++ = KEEPCOPY_PAT_MOD; /*'p'*/
--
1.5.6.3
|
From @cpansproutOn Wed Sep 29 13:00:14 2010, public@khwilliamson.com wrote:
Thank you. |
@cpansprout - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#78040 (status was 'resolved')
Searchable as RT78040$
The text was updated successfully, but these errors were encountered: