Closed Bug 1359980 Opened 8 years ago Closed 8 years ago

Make RegExp parsing give better error messages that point directly at the offending character within the pattern

Categories

(Core :: JavaScript Engine, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla55
Tracking Status
firefox55 --- fixed

People

(Reporter: Waldo, Assigned: Waldo)

Details

Attachments

(1 file)

Simply handling error reporting in regular expression patterns using the current code demands a full-blown TokenStream, but this becomes somewhat problematic as single-byte parsing happens -- because it forces extra template-duplicating for some RegExpParser code, above and beyond just a single/double-byte distinction. Let's create error information based on the actual pattern text to evade this duplication.
Attached patch Patch (deleted) — Splinter Review
Attachment #8862133 - Flags: review?(arai.unmht)
Comment on attachment 8862133 [details] [diff] [review] Patch Review of attachment 8862133 [details] [diff] [review]: ----------------------------------------------------------------- ::: js/src/irregexp/RegExpParser.cpp @@ +287,5 @@ > + > + // The line of context must be null-terminated, and StringBuffer doesn't > + // make that happen unless we force it to. > + if (!windowBuf.append('\0')) > + return; sounds like it's better having dedicated method for appending null-terminator.
Attachment #8862133 - Flags: review?(arai.unmht) → review+
Pushed by jwalden@mit.edu: https://hg.mozilla.org/integration/mozilla-inbound/rev/2c965dfef6c8 Make RegExpParser::ReportError give better error messages that point directly at the offending character within the pattern, rather than just at the start of the RegExp literal. r=arai
Pushed by jwalden@mit.edu: https://hg.mozilla.org/integration/mozilla-inbound/rev/21447217ddbd Followup hazard fix. (Maybe the varargs threw off the hazard analysis, where the suppress-GC operation occurred *inside* a varargs function? *shrug*) r=bustage
Pushed by jwalden@mit.edu: https://hg.mozilla.org/integration/mozilla-inbound/rev/bfd50ac2e7bd Make RegExpParser::ReportError give better error messages that point directly at the offending character within the pattern, rather than just at the start of the RegExp literal. r=arai
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla55
In case anyone is ever curious: there was nothing wrong with this patch. Or with the followup -- which I folded into the relanding because pushing all the varargs stuff as far down as possible, *inside* GC suppression shenanignas, seemed safest for analyzers. The real problem was with the no-bug changesets mentioned in comment 6, which hit a bug in the GC analysis toolchain. Apparently GCC gives non-uniquified names to anonymous types, an anonymous type in the busted code was given a name ".215", and because of how I changed inclusions, an anonymous type in a totally different compilation unit, that *did* contain a GC type, got assigned the same ".215" name. Analysis sees a transitive "GC type" used across a GCing operation, hilarity ensues. At sfink's instructions I worked around this by giving the offending anonymous type that wasn't really a GC type a name, and all returned to wellness. This latter problem is now being tracked in bug 1361444, but in the meantime, if anyone else ever sees a really inscrutable compile error along these lines, try giving names to the complained-about anonymous type to fix it.
Flags: needinfo?(jwalden+bmo)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: