Skip to content
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

antlr4.9.2 cpp runtime static linked program crashes #3238

Closed
digapis-john opened this issue Jul 29, 2021 · 1 comment
Closed

antlr4.9.2 cpp runtime static linked program crashes #3238

digapis-john opened this issue Jul 29, 2021 · 1 comment

Comments

@digapis-john
Copy link

(gdb) bt
#0 0x0000000000000000 in ?? ()
#1 0x00000000007fb62d in std::condition_variable::notify_all() ()
#2 0x00000000007ce164 in antlrcpp::SingleWriteMultipleReadLock::writeUnlock() ()
#3 0x00000000007999da in antlr4::atn::LexerATNSimulator::addDFAState(antlr4::atn::ATNConfigSet*) ()
#4 0x000000000079672c in antlr4::atn::LexerATNSimulator::matchATN(antlr4::CharStream*) ()
#5 0x000000000079738b in antlr4::atn::LexerATNSimulator::match(antlr4::CharStream*, unsigned long) ()
#6 0x000000000077caf8 in antlr4::Lexer::nextToken() ()
#7 0x0000000000416b56 in parsers::MySQLBaseLexer::nextToken (this=0x7fffffffd5d0) at MySQLBaseLexer.cpp:992
#8 0x000000000077a855 in antlr4::BufferedTokenStream::fetch(unsigned long) ()
#9 0x000000000077aba0 in antlr4::BufferedTokenStream::fill() ()
#10 0x0000000000412baa in main () at main.cpp:19
only happens when static-linked, main.cpp is as follows:
include
#include "antlr4-runtime.h"
#include "MySQLLexer.h"
#include "MySQLParser.h"
using namespace antlrcpp;
using namespace parsers;
using namespace antlr4;
#include <stdio.h>

int main(int , const char **) {
FILE *fp = fopen("sql.txt","r");
char line[2048];
if( fp!= NULL ){ fgets(line,2048,fp);fclose(fp); };
//ANTLRInputStream input(u8"select * from test where id=1");
ANTLRInputStream input(line);
parsers::MySQLLexer lexer(&input);
CommonTokenStream tokens(&lexer);

tokens.fill();
for (auto token : tokens.getTokens()) {
std::cout << token->toString() << std::endl;
}

MySQLParser parse(&tokens);
tree::ParseTree* tree = parse.query();

std::cout << tree->toStringTree(&parse) << std::endl << std::endl;

return 0;
}
i get mysql grammer from https://github.com/mysql/mysql-workbench/tree/8.0/library/parsers/grammars

@digapis-john
Copy link
Author

i figured it out,close this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants