Skip to content

xmerl_sax_parser:stream/2 stack keeps growing until the VM is OOM #9190

Closed
@leoliu

Description

Describe the bug
The stack_size of the process running xmerl_sax_parser:stream/2 keeps growing.

To Reproduce
Use xmerl_sax_parser:stream/2 on a large file and observe the stack growing by checking process_info(Pid, stack_size).

Expected behavior
I expect the stream parser to handle infinite stream without blowing up the stack.

Affected versions
Tested on 27.2 but seems all versions are affected.

Additional context
I used xmerl_sax_parser:stream/2 to parse the XML stream from an ejabberd server and noticed after a while the VM is killed by the OOM killer. After some inspection the process has a huge stack_size that keeps growing.

I also verified that removing the error handling in the first two clauses of xmerl_sax_parser_utf8:parse_content/4 and keeping just the cf/5 calls i.e. making it tail-recursive, the stack size is constant.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

bugIssue is reported as a bugteam:PSAssigned to OTP team PS

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions