Closed MarinPostma closed 7 months ago
alright I found it, in parse.y
, this bit:
table_option(A) ::= nm(X). {
if "strict".eq_ignore_ascii_case(&X.0) {
A = TableOptions::STRICT;
}else{
A = TableOptions::NONE;
let msg = format!("unknown table option: {}", &X);
self.ctx.sqlite3_error_msg(&msg);
}
}
generates:
//line 161 "src/parser/parse.y"
{
if "strict".eq_ignore_ascii_case(&self.yy_move(0).yy222().0) {
yylhsminor = YYMINORTYPE::yy201( TableOptions::STRICT);
}else{
yylhsminor = YYMINORTYPE::yy201( TableOptions::NONE);
let msg = format!("unknown table option: {}", &self.yy_move(0).yy222());
self.ctx.sqlite3_error_msg(&msg);
}
}
but the call to yy222
consumes self. on the subsequent call to create the error message, the content of the name was already taken from self.minor
, and it blows up.
changing the rule to:
table_option(A) ::= nm(X). {
let name = X;
if "strict".eq_ignore_ascii_case(&name.0) {
A = TableOptions::STRICT;
}else{
A = TableOptions::NONE;
let msg = format!("unknown table option: {name}");
self.ctx.sqlite3_error_msg(&msg);
}
}
it doesn't panic anymore, but doesn't return an error either. Still investigating.
Indeed, in one action, we are supposed to consume entry once.
I fixed it by immediately returning a ParseError
after self.ctx.sqlite3_error_msg(&msg);
, now it returns an error as expected. LMK if you are interested in these fixes!
I've reapplied your fix here: https://github.com/gwenn/lemon-rs/pull/46/commits/a7cd0c1dbb2da8730dda5e9f01917dc17776b1fd
And I am going to fix all usages of sqlite3_error_msg
.
Thanks for all your feedback.
The following input causes a panic:
CREATE TABLE L(x)L
Not sure what to do about this one, it hits an unreachable statement in parse.rs:
I have many more inputs that trigger that as well, but they all are relatively similar to that one.