[antlr-interest] Segfault in C target on EOF error reporting
Marco Trudel
marco at mtsystems.ch
Fri Feb 4 05:38:44 PST 2011
On 03.02.2011 17:01, Jim Idle wrote:
> I have already fixed this I think.
No. libantlr3c-3.3-SNAPSHOT downloaded 30min ago still crashes.
> It is because the EOF token is trying
> to be duplicated or otherwise modified.
It's because recognizer->state->tokenNames is accessed with the EOF
token type (-1). The garbage returned is then handled as a string and
strlen segfaults. My patch just specially handles the EOF type. No idea
if that's the right fix.
> However, the runtime error message
> routine is just an example - you are expected to implement your own that
> does something sensible ;-)
I have seen you telling that to people over and over again. This
surprises me a little. I would expect that a majority of people just
want to have default error message and have no time/interest in diving
into the antlr internals to write it themselves. If someone still has to
do that, he can invest the time and energy to achieve it.
Actually in 2007 you seemed to have the same idea: "... I am going to
produce an error message handler that will do for most things ..." [1].
Anyway, actually do have my own "displayRecognitionError" routines. But
it's just a copy-paste from yours with the difference that I put
everything into a pANTLR3_STRING so that I can show it to the user in
the GUI.
Thanks
Marco
[1] http://markmail.org/message/27ezjtsvfiglnuyk
> Jim
>
>> -----Original Message-----
>> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
>> bounces at antlr.org] On Behalf Of Marco Trudel
>> Sent: Thursday, February 03, 2011 5:58 AM
>> To: antlr-interest at antlr.org
>> Subject: [antlr-interest] Segfault in C target on EOF error reporting
>>
>> Dear Jim
>>
>> If there's an EOF in the grammar, the C target crashes on input with
>> certain syntax errors. I wrote this quick fix. I hope it at least helps
>> you pinpointing the problem.
>>
>> Any thoughts/comments?
>>
>>
>> Thanks
>> Marco
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
More information about the antlr-interest
mailing list