bug-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Heap Corruption using MSVC (found the issue)


From: Jot Dot
Subject: Re: Heap Corruption using MSVC (found the issue)
Date: Fri, 11 Dec 2020 03:41:10 -0700 (MST)

Hello Akim,

> I spent an awful lot of time tracking your issue, which is:
> 
> %code top
> {
>    #define YYDEBUG 1
>    [...]
> }
> 
> This is dead wrong.  You are *compiling* the parser with YYDEBUG
> set, but to the rest of the application you expose a Parser class
> *without* YYDEBUG.  So you have to different sizes for the same
> class in a one program, of course that does not work (does ODR
> ring a bell?).

Since the ‘parse.trace’ was commented out, we are left with just the
YYDEBUG macro. So I tested this and moved the macro from the
%code top section to the %code requires section.
I noticed that this placed the macro into the parser header, not just
in the source file. Which makes perfect sense.
Sorry, I missed that detail.

That was the issue. Just say that :)
I know what that mistake did - what you said above.

> 
> No wonder that %define parse.trace "fixes" your problem, since it
> defines *properly* YYDEBUG.
> 
> 
> Bottom line: stop messing with macros.

Then change your manual to reflect this.
https://www.gnu.org/software/bison/manual/html_node/Enabling-Traces.html

YYDEBUG is still supported as a POSIX yacc compliant method (for c++ too)
%define parse.trace is a Bison extension, thus not POSIX yacc compliant.

quote just under the YYDEBUG part of that web page:
"We suggest that you always enable the trace option so that debugging is always 
possible."

My take on that web page was that YYDEBUG is the minimum that should be enabled
and that the Bison "extension" 'parse.trace' gives more info than the 
"standard" YYDEBUG.
I can see now that I was wrong.

An "extension" extends. It usually does not mean "alternate way of doing 
exactly the same".
>From what I am hearing, 'parse.trace' is just that. Borrowing your phrase: 
>"(does ODR ring a bell?)"

A "Suggested Improvement":

My suggestion is to edit that web page:

1) Mention the parse.trace is simply a far less error prone alternative to the 
YYDEBUG macro.
2) If POSIX compliance is preferred and YYDEBUG is used, the proper placement 
of the YYDEBUG macro
is in the %code requires section, not %code top (for us newbies)
3) change the line:
"We suggest that you always enable the trace option so that debugging is always 
possible."
to:
"We suggest that you always enable one of the above options so that debugging 
is always possible."


Sorry to waste your time, thanks for the effort.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]