dlang-community / libdparse

Library for lexing and parsing D source code
https://libdparse.dlang.io
Boost Software License 1.0
114 stars 56 forks source link

bounds violation in `parsePragmaStatement` #459

Closed ghost closed 1 year ago

ghost commented 2 years ago

This happens on invalid code (or code being written)

void main()
{
    pragma(msg, "add a `" ~ A.stringof ~ "`for " ~ t.stringof");
}
#0 raise at :0
#1 abort at :0
#2 _d_throw_exception at :0
#3 onArrayIndexError at :0
#4 _d_arraybounds_index at :0
#5 dparse.parser.Parser.current() const(0x7fffd729a0b0) at ../etc/libdparse/src/dparse/parser.d:8779
#6 dparse.parser.Parser.parsePragmaStatement()(0x7fffd729a0b0) at ../etc/libdparse/src/dparse/parser.d:5536
#7 dparse.parser.Parser.parseStatementNoCaseNoDefault()(0x7fffd729a0b0) at ../etc/libdparse/src/dparse/parser.d-mixin-6120:6120
#8 dparse.parser.Parser.parseStatement()(0x7fffd729a0b0) at ../etc/libdparse/src/dparse/parser.d-mixin-6023:6023
#9 dparse.parser.Parser.parseDeclarationOrStatement()(0x7fffd729a0b0) at ../etc/libdparse/src/dparse/parser.d-mixin-2533:2533
#10 dparse.parser.Parser.parseDeclarationsAndStatements(bool)(0x7fffd729a0b0, true) at ../etc/libdparse/src/dparse/parser.d:2479
#11 dparse.parser.Parser.parseBlockStatement()(0x7fffd729a0b0) at ../etc/libdparse/src/dparse/parser.d-mixin-1392:1392
#12 dparse.parser.Parser.parseSpecifiedFunctionBody()(0x7fffd729a0b0) at ../etc/libdparse/src/dparse/parser.d-mixin-5982:5982
#13 dparse.parser.Parser.parseFunctionBody()(0x7fffd729a0b0) at ../etc/libdparse/src/dparse/parser.d-mixin-3418:3418
#14 dparse.parser.Parser.parseFunctionDeclaration(dparse.ast.Type, bool, dparse.ast.Attribute[])(0x7fffd729a0b0, 0x7fffc4012210, false, 0x0) at ../etc/libdparse/src/dparse/parser.d-mixin-3563:3563
#15 dparse.parser.Parser.parseDeclaration(bool, bool, bool)(0x7fffd729a0b0, true, true, false) at ../etc/libdparse/src/dparse/parser.d:2415
#16 dparse.parser.Parser.parseModule()(0x7fffd729a0b0) at ../etc/libdparse/src/dparse/parser.d:4865
#17 dparse.parser.parseModule!().parseModule(dparse.parser.ParserConfig)({tokens = {length = 21, ptr = 0x7fffe4f52000}, fileName = {length = 0, ptr = 0x7ffff7d36d28 ''}, allocator = 0x7fffcf729a78, messageFunction = 0x0, messageDelegate = {context = 0x7fffd729c150 ' >*'#215#255#127, funcptr = 0x7ffff7906b50 <_D7symlist11listSymbolsUPxabZ12handleErrorsMFNfAyammQfbZv>}, errorCount = 0x0, warningCount = 0x0}) at ../etc/libdparse/src/dparse/parser.d:71
#18 dparse.parser.parseModule!(void(immutable(char)[], ulong, ulong, immutable(char)[], bool) @safe delegate).parseModule(const(std.experimental.lexer.TokenStructure!(ubyte, \"import dparse.lexer:TokenTriviaFields; mixin TokenTriviaFields;\").TokenStructure)[], immutable(char)[], dparse.rollback_allocator.RollbackAllocator*, void(immutable(char)[], ulong, ulong, immutable(char)[], bool) @safe delegate, uint*, uint*)({{text = {length = 0, ptr = 0x0}, line = 1, column = 1, index = 0, type = 178, leadingTrivia = {length = 0, ptr = 0x0}, trailingTrivia = {length = 1, ptr = 0x7fffd729b100}, memoizedLeadingComment = {length = 0, ptr = 0x0}, memoizedTrailingComment = {length = 0, ptr = 0x0}}, {text = {length = 4, ptr = 0x7fffc4021ab1 'main'#10#10'    msg"add a `"Ast'...}, line = 1, column = 6, index = 5, type = 65, leadingTrivia = {length = 0, ptr = 0x0}, trailingTrivia = {length = 0, ptr = 0x0}, memoizedLeadingComment = {length = 0, ptr = 0x0}, memoizedTrailingComment = {length = 0, ptr = 0x0}}, {text = {length = 0, ptr = 0x0}, line = 1, column = 10, index = 9, type = 21, leadingTrivia = {length = 0, ptr = 0x0}, trailingTrivia = {length = 0, ptr = 0x0}, memoizedLeadingComment = {length = 0, ptr = 0x0}, memoizedTrailingComment = {length = 0, ptr = 0x0}}, {text = {length = 0, ptr = 0x0}, line = 1, column = 11, index = 10, type = 22, leadingTrivia = {length = 0, ptr = 0x0}, trailingTrivia = {length = 1, ptr = 0x7fffd729b180}, memoizedLeadingComment = {length = 0, ptr = 0x0}, memoizedTrailingComment = {length = 0, ptr = 0x0}}, {text = {length = 0, ptr = 0x0}, line = 2, column = 1, index = 12, type = 56, leadingTrivia = {length = 0, ptr = 0x0}, trailingTrivia = {length = 1, ptr = 0x7fffd729b200}, memoizedLeadingComment = {length = 0, ptr = 0x0}, memoizedTrailingComment = {length = 0, ptr = 0x0}}, {text = {length = 0, ptr = 0x0}, line = 3, column = 5, index = 18, type = 146, leadingTrivia = {length = 0, ptr = 0x0}, trailingTrivia = {length = 0, ptr = 0x0}, memoizedLeadingComment = {length = 0, ptr = 0x0}, memoizedTrailingComment = {length = 0, ptr = 0x0}}, {text = {length = 0, ptr = 0x0}, line = 3, column = 11, index = 24, type = 21, leadingTrivia = {length = 0, ptr = 0x0}, trailingTrivia = {length = 0, ptr = 0x0}, memoizedLeadingComment = {length = 0, ptr = 0x0}, memoizedTrailingComment = {length = 0, ptr = 0x0}}, {text = {length = 3, ptr = 0x7fffc4021abb 'msg"add a `"Astringof"`fo'...}, line = 3, column = 12, index = 25, type = 65, leadingTrivia = {length = 0, ptr = 0x0}, trailingTrivia = {length = 0, ptr = 0x0}, memoizedLeadingComment = {length = 0, ptr = 0x0}, memoizedTrailingComment = {length = 0, ptr = 0x0}}, {text = {length = 0, ptr = 0x0}, line = 3, column = 15, index = 28, type = 1, leadingTrivia = {length = 0, ptr = 0x0}, trailingTrivia = {length = 1, ptr = 0x7fffd729b280}, memoizedLeadingComment = {length = 0, ptr = 0x0}, memoizedTrailingComment = {length = 0, ptr = 0x0}}, {text = {length = 9, ptr = 0x7fffc4021abe '"add a `"Astringof"`for "'...}, line = 3, column = 17, index = 30, type = 80, leadingTrivia = {length = 0, ptr = 0x0}, trailingTrivia = {length = 1, ptr = 0x7fffd729b300}, memoizedLeadingComment = {length = 0, ptr = 0x0}, memoizedTrailingComment = {length = 0, ptr = 0x0}}, {text = {length = 0, ptr = 0x0}, line = 3, column = 27, index = 40, type = 61, leadingTrivia = {length = 0, ptr = 0x0}, trailingTrivia = {length = 1, ptr = 0x7fffd729b380}, memoizedLeadingComment = {length = 0, ptr = 0x0}, memoizedTrailingComment = {length = 0, ptr = 0x0}}, {text = {length = 1, ptr = 0x7fffc4021ac7 'Astringof"`for "t'}, line = 3, column = 29, index = 42, type = 65, leadingTrivia = {length = 0, ptr = 0x0}, trailingTrivia = {length = 0, ptr = 0x0}, memoizedLeadingComment = {length = 0, ptr = 0x0}, memoizedTrailingComment = {length = 0, ptr = 0x0}}, {text = {length = 0, ptr = 0x0}, line = 3, column = 30, index = 43, type = 2, leadingTrivia = {length = 0, ptr = 0x0}, trailingTrivia = {length = 0, ptr = 0x0}, memoizedLeadingComment = {length = 0, ptr = 0x0}, memoizedTrailingComment = {length = 0, ptr = 0x0}}, {text = {length = 8, ptr = 0x7fffc4021ac8 'stringof"`for "t'}, line = 3, column = 31, index = 44, type = 65, leadingTrivia = {length = 0, ptr = 0x0}, trailingTrivia = {length = 1, ptr = 0x7fffd729b400}, memoizedLeadingComment = {length = 0, ptr = 0x0}, memoizedTrailingComment = {length = 0, ptr = 0x0}}, {text = {length = 0, ptr = 0x0}, line = 3, column = 40, index = 53, type = 61, leadingTrivia = {length = 0, ptr = 0x0}, trailingTrivia = {length = 1, ptr = 0x7fffd729b480}, memoizedLeadingComment = {length = 0, ptr = 0x0}, memoizedTrailingComment = {length = 0, ptr = 0x0}}, {text = {length = 7, ptr = 0x7fffc4021ad0 '"`for "t'}, line = 3, column = 42, index = 55, type = 80, leadingTrivia = {length = 0, ptr = 0x0}, trailingTrivia = {length = 1, ptr = 0x7fffd729b500}, memoizedLeadingComment = {length = 0, ptr = 0x0}, memoizedTrailingComment = {length = 0, ptr = 0x0}}, {text = {length = 0, ptr = 0x0}, line = 3, column = 50, index = 63, type = 61, leadingTrivia = {length = 0, ptr = 0x0}, trailingTrivia = {length = 1, ptr = 0x7fffd729b580}, memoizedLeadingComment = {length = 0, ptr = 0x0}, memoizedTrailingComment = {length = 0, ptr = 0x0}}, {text = {length = 1, ptr = 0x7fffc4021ad7 't'}, line = 3, column = 52, index = 65, type = 65, leadingTrivia = {length = 0, ptr = 0x0}, trailingTrivia = {length = 0, ptr = 0x0}, memoizedLeadingComment = {length = 0, ptr = 0x0}, memoizedTrailingComment = {length = 0, ptr = 0x0}}, {text = {length = 0, ptr = 0x0}, line = 3, column = 53, index = 66, type = 2, leadingTrivia = {length = 0, ptr = 0x0}, trailingTrivia = {length = 0, ptr = 0x0}, memoizedLeadingComment = {length = 0, ptr = 0x0}, memoizedTrailingComment = {length = 0, ptr = 0x0}}, {text = {length = 8, ptr = 0x7fffc4021ac8 'stringof"`for "t'}, line = 3, column = 54, index = 67, type = 65, leadingTrivia = {length = 0, ptr = 0x0}, trailingTrivia = {length = 0, ptr = 0x0}, memoizedLeadingComment = {length = 0, ptr = 0x0}, memoizedTrailingComment = {length = 0, ptr = 0x0}}, {text = {length = 0, ptr = 0x0}, line = 0, column = 0, index = 0, type = 0, leadingTrivia = {length = 0, ptr = 0x0}, trailingTrivia = {length = 0, ptr = 0x0}, memoizedLeadingComment = {length = 0, ptr = 0x0}, memoizedTrailingComment = {length = 0, ptr = 0x0}}}, 0x7ffff7d36d28 '', 0x7fffcf729a78, {context = 0x7fffd729c150 ' >*'#215#255#127, funcptr = 0x7ffff7906b50 <_D7symlist11listSymbolsUPxabZ12handleErrorsMFNfAyammQfbZv>}, 0x0, 0x0) at ../etc/libdparse/src/dparse/parser.d:102
#19 listSymbols(0x7fffcd3f85d8 'void main()'#10'{'#10'    pragma('..., true) at ../dexed-d/src/symlist.d:41
#20 THREADEDPARSING(0x7fffe6f35810) at ../src/u_symlist.pas:752
#21 CLASSES$_$TSIMPLETHREAD_$__$$_EXECUTE at :0
#22 ?? at :0
#23 CLASSES_$$_THREADFUNC$POINTER$$INT64 at :0
#24 ?? at :0
#25 ?? at :0
#26 ?? at :0
#27 ?? at :0
#28 ?? at :0
#29 ?? at :0
ghost commented 2 years ago

looks like that #403 covered this issue.