Skip to content

stack exhaustion in tidy-html5 5.1.25 #343

Closed
@gaa-cifasis

Description

@gaa-cifasis

Hello,

We found a stack exhaustion in tidy-html5 (version: 5.1.25). You can find a test case to reproduce it here [1.4MB]. Technical details are here:

$ gdb -ex 'tty /dev/null' --args ./tidy exhaustion.html
(gdb) run
Starting program: ./tidy exhaustion.html
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff4e53b2b in ?? () from /usr/lib/x86_64-linux-gnu/libasan.so.0
(gdb)
(gdb) bt
#0 0x00007ffff4e53b2b in ?? () from /usr/lib/x86_64-linux-gnu/libasan.so.0
#1 0x00007ffff4e60443 in malloc () from /usr/lib/x86_64-linux-gnu/libasan.so.0
#2 0x000000000047c581 in defaultAlloc (allocator=0x721de0 <prvTidyg_default_allocator>, size=2048)

at /home/vagrant/repos/tidy-html5-5.1.25/src/alloc.c:59

#3 0x000000000040ecf6 in messagePos (doc=0x607c00018900, level=TidyWarning, line=6169, col=44, msg=0x497f60 "nested emphasis %s",

args=0x7fffff7ff9f0) at /home/vagrant/repos/tidy-html5-5.1.25/src/localize.c:1225

#4 0x000000000040f9da in messageNode (doc=0x607c00018900, level=TidyWarning, node=0x601600f086d0, msg=0x497f60 "nested emphasis %s")

at /home/vagrant/repos/tidy-html5-5.1.25/src/localize.c:1343

#5 0x00000000004113d5 in prvTidyReportWarning (doc=0x607c00018900, element=0x601600f086d0, node=0x601600f08620, code=9)

at /home/vagrant/repos/tidy-html5-5.1.25/src/localize.c:1681

#6 0x000000000043bcdd in prvTidyParseInline (doc=0x607c00018900, element=0x601600f086d0, mode=MixedContent)

at /home/vagrant/repos/tidy-html5-5.1.25/src/parser.c:1757

#7 0x0000000000436ecf in ParseTag (doc=0x607c00018900, node=0x601600f086d0, mode=MixedContent)

at /home/vagrant/repos/tidy-html5-5.1.25/src/parser.c:775

#8 0x000000000043e07a in prvTidyParseInline (doc=0x607c00018900, element=0x601600f08780, mode=MixedContent)

at /home/vagrant/repos/tidy-html5-5.1.25/src/parser.c:2202

#9 0x0000000000436ecf in ParseTag (doc=0x607c00018900, node=0x601600f08780, mode=MixedContent)

at /home/vagrant/repos/tidy-html5-5.1.25/src/parser.c:775

#10 0x000000000043e07a in prvTidyParseInline (doc=0x607c00018900, element=0x601600f08830, mode=MixedContent)

at /home/vagrant/repos/tidy-html5-5.1.25/src/parser.c:2202

#11 0x0000000000436ecf in ParseTag (doc=0x607c00018900, node=0x601600f08830, mode=MixedContent)

at /home/vagrant/repos/tidy-html5-5.1.25/src/parser.c:775

#12 0x000000000043e07a in prvTidyParseInline (doc=0x607c00018900, element=0x601600f088e0, mode=MixedContent)

at /home/vagrant/repos/tidy-html5-5.1.25/src/parser.c:2202

#13 0x0000000000436ecf in ParseTag (doc=0x607c00018900, node=0x601600f088e0, mode=MixedContent)

at /home/vagrant/repos/tidy-html5-5.1.25/src/parser.c:775

#14 0x000000000043e07a in prvTidyParseInline (doc=0x607c00018900, element=0x601600f08990, mode=MixedContent)

at /home/vagrant/repos/tidy-html5-5.1.25/src/parser.c:2202

#15 0x0000000000436ecf in ParseTag (doc=0x607c00018900, node=0x601600f08990, mode=MixedContent)

at /home/vagrant/repos/tidy-html5-5.1.25/src/parser.c:775

#16 0x000000000043e07a in prvTidyParseInline (doc=0x607c00018900, element=0x601600f08a40, mode=MixedContent)

at /home/vagrant/repos/tidy-html5-5.1.25/src/parser.c:2202

#17 0x0000000000436ecf in ParseTag (doc=0x607c00018900, node=0x601600f08a40, mode=MixedContent)

at /home/vagrant/repos/tidy-html5-5.1.25/src/parser.c:775

#18 0x000000000043e07a in prvTidyParseInline (doc=0x607c00018900, element=0x601600f08f10, mode=MixedContent)

at /home/vagrant/repos/tidy-html5-5.1.25/src/parser.c:2202

#19 0x0000000000436ecf in ParseTag (doc=0x607c00018900, node=0x601600f08f10, mode=MixedContent)

at /home/vagrant/repos/tidy-html5-5.1.25/src/parser.c:775

#20 0x000000000043e07a in prvTidyParseInline (doc=0x607c00018900, element=0x601600f08fc0, mode=MixedContent)

at /home/vagrant/repos/tidy-html5-5.1.25/src/parser.c:2202

#21 0x0000000000436ecf in ParseTag (doc=0x607c00018900, node=0x601600f08fc0, mode=MixedContent)

at /home/vagrant/repos/tidy-html5-5.1.25/src/parser.c:775

#22 0x000000000043e07a in prvTidyParseInline (doc=0x607c00018900, element=0x601600f09070, mode=MixedContent)

at /home/vagrant/repos/tidy-html5-5.1.25/src/parser.c:2202

#23 0x0000000000436ecf in ParseTag (doc=0x607c00018900, node=0x601600f09070, mode=MixedContent)

---Type to continue, or q to quit---q

(.. really long back trace)

In my opinion, tidy-html5 shouldn't crash because you can force it to execute a really long sequence of functions calls (tail recursion maybe can help?).

Regards,
Gus.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions