-
-
Notifications
You must be signed in to change notification settings - Fork 304
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
formatting file with zls causes infinite loop in memory allocator #979
Comments
Known issue relating to diffing large incremental edits using our current algorithm |
i don't know if this would work but what if when the input is longer than say 8 KB and the buffer is to a file on the filesystem, it spawns |
I’ll try to optimize this tonight. |
Reproduced and got a beautiful |
If the code is still using That means using |
That is incorrect. Firstly, we use an Arena, so this is practically a non-issue as far as I know. Secondly, the method that |
to speed up mem.eql(u8, slice, slice), consider copying this function https://github.com/oven-sh/bun/blob/main/src/string_immutable.zig#L766-L824 to speed up ComptimeStringMap, consider copying this https://github.com/oven-sh/bun/blob/main/src/comptime_string_map.zig#L1 |
These optimizations are not useful in this scenario. |
Zig Version
0.11.0-dev.1393+38eebf3c4
Zig Language Server Version
384f227
Steps to Reproduce
When using zls to format files, it seems to infinite loop on certain input. Generally it seems to be more likely to happen on longer files.
zig fmt
works as expected.File that reproduces the issue (too long to fit in an issue)
Expected Behavior
Formats successfully, like
zig fmt
Actual Behavior
It infinite loops until it uses enough memory for the OOM killer to kill it. This type of issue is often caused by looping over or duplicating a slice that is undefined, in which cause the
len
field is something absurdly large (due to undefined memory)The text was updated successfully, but these errors were encountered: