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

Assertion failure for specific markdown file #57

Open
dozed opened this issue Jun 26, 2023 · 0 comments
Open

Assertion failure for specific markdown file #57

dozed opened this issue Jun 26, 2023 · 0 comments

Comments

@dozed
Copy link

dozed commented Jun 26, 2023

The markdown parser fails for the following input: https://gist.github.com/dozed/411fa82c314772f4c57349aa9d88c86d

Reproduce:

const Parser = require('tree-sitter');
const Markdown = require('./build/Release/tree_sitter_markdown_binding');
const parser = new Parser();
parser.setLanguage(Markdown);
const text = fs.readFileSync('Test.md', 'utf8')
const tree = parser.parse(text);
tree

Results in:

terminate called after throwing an instance of 'int'
[1]    268688 IOT instruction (core dumped)  node

It seems to fail in: https://github.com/ikatyang/tree-sitter-markdown/blob/master/src/scanner.cc#L56

The relevant stacktrace in Emacs:

emacs: src/scanner.cc:56: unsigned int {anonymous}::Scanner::serialize(unsigned char*): Assertion `i <= 1024' failed.

Thread 1 "emacs" received signal SIGABRT, Aborted.
__pthread_kill_implementation (no_tid=0, signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:44
44	./nptl/pthread_kill.c: No such file or directory.
(gdb) bt
#0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:44
#1  __pthread_kill_internal (signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:78
#2  __GI___pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
#3  0x00007fffee23c406 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#4  0x00007fffee22287c in __GI_abort () at ./stdlib/abort.c:79
#5  0x00007fffee22279b in __assert_fail_base
    (fmt=0x7fffee3b9f68 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x7fffe40d66d9 "i <= 1024", file=file@entry=0x7fffe40d66ca "src/scanner.cc", line=line@entry=56, function=function@entry=0x7fffe40d3f20 "unsigned int {anonymous}::Scanner::serialize(unsigned char*)") at ./assert/assert.c:92
#6  0x00007fffee233b86 in __assert_fail
    (assertion=assertion@entry=0x7fffe40d66d9 "i <= 1024", file=file@entry=0x7fffe40d66ca "src/scanner.cc", line=line@entry=56, function=function@entry=0x7fffe40d3f20 "unsigned int {anonymous}::Scanner::serialize(unsigned char*)")
    at ./assert/assert.c:101
#7  0x00007fffe407fa49 in (anonymous namespace)::Scanner::serialize (buffer=0x55555be60f65 "\002", this=0x55555bcc10c0) at src/scanner.cc:56
#8  tree_sitter_markdown_external_scanner_serialize(void*, char*) (payload=0x55555bcc10c0, buffer=0x55555be60f65 "\002") at src/scanner.cc:301
#9  0x00007fffdeb4e340 in ts_parser_parse () at /home/user/.emacs.d/elpa/tsc-20220212.1632/tsc-dyn.so
#10 0x00007fffdeb2d0d1 in tsc_dyn::parser::__emr_O_parse_chunks::h8c1adc3341858b2b () at /home/user/.emacs.d/elpa/tsc-20220212.1632/tsc-dyn.so
#11 0x00007fffdeb28a6a in std::panicking::try::h5d5045dd90c5b416 () at /home/user/.emacs.d/elpa/tsc-20220212.1632/tsc-dyn.so
#12 0x00007fffdeb2d526 in tsc_dyn::parser::__emrs_E_parse_chunks::extern_lambda::hd67f0f0313299272 () at /home/user/.emacs.d/elpa/tsc-20220212.1632/tsc-dyn.so
#13 0x00005555558b6797 in funcall_module (function=..., nargs=3, arglist=0x7fffe87ff228) at emacs-module.c:1183
#14 0x000055555585df8e in funcall_lambda (fun=..., nargs=3, arg_vector=0x7fffe87ff228) at eval.c:3162
#15 0x000055555585d0b4 in funcall_general (fun=..., numargs=3, args=0x7fffe87ff228) at eval.c:2945
#16 0x00005555558c64fb in exec_byte_code (fun=..., args_template=0, nargs=0, args=0x7fffe87ff180) at bytecode.c:811
#17 0x000055555585da49 in fetch_and_exec_byte_code (fun=..., args_template=771, nargs=3, args=0x7fffffffc808) at eval.c:3081
#18 0x000055555585df53 in funcall_lambda (fun=..., nargs=3, arg_vector=0x7fffffffc808) at eval.c:3153
#19 0x000055555585d0b4 in funcall_general (fun=..., numargs=3, args=0x7fffffffc808) at eval.c:2945
#20 0x000055555585d3cc in Ffuncall (nargs=4, args=0x7fffffffc800) at eval.c:2995
#21 0x000055555585c58c in funcall_nil (nargs=4, args=0x7fffffffc800) at eval.c:2677
#22 0x000055555585cb1a in run_hook_with_args (nargs=4, args=0x7fffffffc800, funcall=0x55555585c565 <funcall_nil>) at eval.c:2854
#23 0x000055555585c61d in Frun_hook_with_args (nargs=4, args=0x7fffffffc800) at eval.c:2719
#24 0x00005555557b958d in signal_after_change (charpos=648, lendel=0, lenins=1) at insdel.c:2283
#25 0x00005555557b3507 in insert_and_inherit (string=0x7fffffffc953 "``", nbytes=1) at insdel.c:696
#26 0x00005555557dd4de in internal_self_insert (c=96, n=1) at cmds.c:472
#27 0x00005555557dc911 in Fself_insert_command (n=..., c=...) at cmds.c:294
#28 0x000055555585d674 in funcall_subr (subr=0x555556033c20 <Sself_insert_command>, numargs=1, args=0x7fffe87ff100) at eval.c:3036
#29 0x00005555558c64d8 in exec_byte_code (fun=..., args_template=257, nargs=1, args=0x7fffffffd218) at bytecode.c:809
#30 0x000055555585da49 in fetch_and_exec_byte_code (fun=..., args_template=257, nargs=1, args=0x7fffffffd210) at eval.c:3081
#31 0x000055555585df53 in funcall_lambda (fun=..., nargs=1, arg_vector=0x7fffffffd210) at eval.c:3153
#32 0x000055555585d0b4 in funcall_general (fun=..., numargs=1, args=0x7fffffffd210) at eval.c:2945
#33 0x000055555585d3cc in Ffuncall (nargs=2, args=0x7fffffffd208) at eval.c:2995
#34 0x000055555584ef5c in Ffuncall_interactively (nargs=2, args=0x7fffffffd208) at callint.c:250
#35 0x000055555585d8b1 in funcall_subr (subr=0x55555603a220 <Sfuncall_interactively>, numargs=2, args=0x7fffffffd208) at eval.c:3059
#36 0x000055555585d068 in funcall_general (fun=..., numargs=2, args=0x7fffffffd208) at eval.c:2941
#37 0x000055555585d3cc in Ffuncall (nargs=3, args=0x7fffffffd200) at eval.c:2995
#38 0x00005555558518ab in Fcall_interactively (function=..., record_flag=..., keys=...) at callint.c:787
#39 0x000055555585d6aa in funcall_subr (subr=0x55555603a280 <Scall_interactively>, numargs=3, args=0x7fffe87ff070) at eval.c:3038
#40 0x00005555558c64d8 in exec_byte_code (fun=..., args_template=1025, nargs=1, args=0x7fffffffdb20) at bytecode.c:809
#41 0x000055555585da49 in fetch_and_exec_byte_code (fun=..., args_template=1025, nargs=1, args=0x7fffffffdb18) at eval.c:3081
#42 0x000055555585df53 in funcall_lambda (fun=..., nargs=1, arg_vector=0x7fffffffdb18) at eval.c:3153
#43 0x000055555585d0b4 in funcall_general (fun=..., numargs=1, args=0x7fffffffdb18) at eval.c:2945
#44 0x000055555585d3cc in Ffuncall (nargs=2, args=0x7fffffffdb10) at eval.c:2995
#45 0x000055555575dadb in call1 (fn=..., arg1=...) at /home/user/Code/tools/emacs-29/src/lisp.h:3247
#46 0x00005555557615f1 in command_loop_1 () at keyboard.c:1503
#47 0x00005555558583fe in internal_condition_case (bfun=0x555555760d45 <command_loop_1>, handlers=..., hfun=0x5555557600ce <cmd_error>) at eval.c:1474
#48 0x00005555557608da in command_loop_2 (handlers=...) at keyboard.c:1133
#49 0x00005555558574b5 in internal_catch (tag=..., func=0x5555557608ac <command_loop_2>, arg=...) at eval.c:1197
#50 0x0000555555760868 in command_loop () at keyboard.c:1111
#51 0x000055555575fb50 in recursive_edit_1 () at keyboard.c:720
#52 0x000055555575fd84 in Frecursive_edit () at keyboard.c:803
#53 0x000055555575b047 in main (argc=1, argv=0x7fffffffe048) at emacs.c:2529
@dozed dozed changed the title Segmentation fault for specific markdown file Assertion failure for specific markdown file Jun 29, 2023
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

1 participant