Heap Corruption

Jot Dot <[email protected]> Wed, 9 Dec 2020 19:21:43 -0700 (MST)
Newsgroups gmane.comp.parsers.bison.general
Message-ID <[email protected]>
I'm at a loss.

I have set up a c++ scanner/parser to run on the command line (windows).
The parser corrupts the heap. I have no clue at all what I am doing wrong.

I think I have set everything up correctly and everything compiles without
any issue. I have defined a parser class, a lexer class, and my own driver
class. This driver class is passed to the lexer and parser. My .l and .y
files are copies of what I have already set up in a DLL - which does not
have this issue.

I am not sure what to post (unnecessary clutter?) but below is what I
believe is a confirmation of my issue.

Note: I simply construct the parser and delete it immediately - and get a
heap corruption error.Tracing thru the code, it looks like it is simply
establishing the stack (when creating the Parser).

Anyone have a similar issue? Any ideas are welcome.
I'll post anything anybody wants to look at.

Thanks

//----------------
class Driver
{
protected:
	gen::Parser* pParser;
	gen::Scanner* pScanner;
	ParseResults* pResult;

public:
    Driver()
    {
        pResult = new ParseResults; 		// Test ok
        delete pResult;				// Test ok
        pResult = new ParseResults;
        pScanner = new gen::Scanner(this);	// Test ok
        delete pScanner;			// Test ok
        pScanner = new gen::Scanner(this);
        pParser = new gen::Parser(this);	// Test ok
        delete pParser;				// Test <= FAIL: Heap Corruption
        pParser = new gen::Parser(this);
    }

    virtual ~Driver()
    {
        delete pScanner;
        delete pParser;
        delete pResult;
    }

    gen::Parser* getParser() const { return pParser; }
    gen::Scanner* getScanner() const { return pScanner; }
    ParseResults* getResult() const { return pResult; }
};