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

Panic in deno 1.46 fmt for large swagger-ui file #28519

Open
rgrannell1 opened this issue Mar 16, 2025 · 3 comments
Open

Panic in deno 1.46 fmt for large swagger-ui file #28519

rgrannell1 opened this issue Mar 16, 2025 · 3 comments
Labels
deno fmt Related to the "deno fmt" subcommand or dprint

Comments

@rgrannell1
Copy link

I ran into a deno fmt panic for this file. Reporting as requested

deno --version
deno 1.46.3 (stable, release, x86_64-unknown-linux-gnu)
v8 12.9.202.5-rusty
typescript 5.5.2

https://gist.github.com/rgrannell1/1944f8be41240f7eda221113add195c2


============================================================
Deno has panicked. This is a bug in Deno. Please report this
at https://github.com/denoland/deno/issues/new.
If you can reliably reproduce this panic, include the
reproduction steps and re-run with the RUST_BACKTRACE=1 env
var set and include the backtrace in your report.

Platform: linux x86_64
Version: 1.46.3
Args: ["deno", "fmt"]

thread 'tokio-runtime-worker' panicked at cli/tools/fmt.rs:754:11:
Formatting not stable. Bailed after 5 tries. This indicates a bug in the formatter where it formats the file (/home/rg/Code/websites/ui.common-storage.rgrannell.xyz/swagger-ui.js) differently each time. As a temporary workaround you can ignore this file.
stack backtrace:
0: 0x5946e89ff635 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hd736fd5964392270
1: 0x5946e8a3201b - core::fmt::write::hc6043626647b98ea
2: 0x5946e89f969f - std::io::Write::write_fmt::h0d24b3e0473045db
3: 0x5946e89ff40e - std::sys_common::backtrace::print::h45eb8174d25a1e76
4: 0x5946e8a00e79 - std::panicking::default_hook::{{closure}}::haf3f0170eb4f3b53
5: 0x5946e8a00c1a - std::panicking::default_hook::hb5d3b27aa9f6dcda
6: 0x5946e901a7ed - deno::setup_panic_hook::{{closure}}::h33552738c951bb34
7: 0x5946e8a014eb - std::panicking::rust_panic_with_hook::h6b49d59f86ee588c
8: 0x5946e8a01264 - std::panicking::begin_panic_handler::{{closure}}::hd4c2f7ed79b82b70
9: 0x5946e89ffaf9 - std::sys_common::backtrace::__rust_end_short_backtrace::h2946d6d32d7ea1ad
10: 0x5946e8a00f97 - rust_begin_unwind
11: 0x5946e8a2ef33 - core::panicking::panic_fmt::ha02418e5cd774672
12: 0x5946e8c691db - tokio::runtime::task::raw::poll::hbe947dca81b8a0fc
13: 0x5946ead70e70 - std::sys_common::backtrace::__rust_begin_short_backtrace::h441af42626d0a10d
14: 0x5946ead735f2 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h506cb4efabbeeb1b
15: 0x5946e8a0832b - std::sys::pal::unix::thread::Thread::new::thread_start::hb85dbfa54ba503d6
16: 0x7c4142ea1e2e - start_thread
at ./nptl/pthread_create.c:447:8
17: 0x7c4142f33a4c - __GI___clone3
at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
18: 0x0 -

@marvinhagemeister
Copy link
Contributor

marvinhagemeister commented Mar 16, 2025

Looks like it's not panicking anymore in the latest version of Deno 2.2.4, but it fails to format either way:

Error formatting: /Users/marvinhagemeister/dev/test/deno-fmt-foo/main.ts
   Formatting not stable. Bailed after 5 tries. This indicates a bug in the formatter where it formats the file differently each time. As a temporary workaround you can ignore this file.
Checked 1 file

@marvinhagemeister marvinhagemeister added the deno fmt Related to the "deno fmt" subcommand or dprint label Mar 16, 2025
@rgrannell1
Copy link
Author

rgrannell1 commented Mar 16, 2025

deno 2.2.4 (stable, release, x86_64-unknown-linux-gnu)
v8 13.4.114.11-rusty
typescript 5.7.3

running deno fmt against ~/Code/websites (which has a lot of code) still has unstable formatting and

Error formatting: /home/rg/Code/websites/ui.common-storage.rgrannell.xyz/swagger-ui.js
   Formatting not stable. Bailed after 5 tries. This indicates a bug in the formatter where it formats the file differently each time. As a temporary workaround you can ignore this file.
Error formatting: /home/rg/Code/websites/ui.common-storage.rgrannell.xyz/swagger-ui-es-bundle.js
   Formatting not stable. Bailed after 5 tries. This indicates a bug in the formatter where it formats the file differently each time. As a temporary workaround you can ignore this file.
[1]    32031 killed     deno fmt

the process OOMs

strace -f -o traced -e trace=file deno fmt

Image

It opened 444 distinct files (syscall open or openat)

Error formatting: /home/rg/Code/websites/photos.rgrannell.xyz/manifest/albums.06372c4737.json
   Line 1, column 401: Invalid unicode escape sequence. 'd83c' is not a valid UTF8 character

components/date.js", O_RDONLY|O_CLOEXEC <unfinished ...>
34181 <... openat resumed>)             = 16
34183 <... openat resumed>)             = 17
34181 statx(16, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_ALL,  <unfinished ...>
34183 statx(17, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_ALL,  <unfinished ...>
34181 <... statx resumed>{stx_mask=STATX_ALL|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0664, stx_size=2239, ...}) = 0
34183 <... statx resumed>{stx_mask=STATX_ALL|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0664, stx_size=591, ...}) = 0
34188 openat(AT_FDCWD, "/home/rg/Code/websites/borg.rgrannell.xyz/static/js/views/pages/view-database/components/search-bar.js", O_RDONLY|O_CLOEXEC) = 18
34188 statx(18, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_ALL, {stx_mask=STATX_ALL|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0664, stx_size=877, ...}) = 0
34192 +++ exited with 0 +++
34189 +++ exited with 0 +++
34184 +++ exited with 0 +++
34186 +++ exited with 0 +++
34191 +++ exited with 0 +++
34190 +++ exited with 0 +++
34178 +++ exited with 0 +++
34179 +++ exited with 0 +++
34187 +++ exited with 0 +++
34183 +++ exited with 0 +++
34181 +++ exited with 0 +++
34188 +++ exited with 0 +++
34185 +++ exited with 0 +++
34182 openat(AT_FDCWD, "/proc/sys/vm/overcommit_memory", O_RDONLY|O_CLOEXEC) = 16
34182 +++ killed by SIGKILL +++
34180 +++ killed by SIGKILL +++
34173 +++ killed by SIGKILL +++
34172 +++ killed by SIGKILL +++
34171 +++ killed by SIGKILL +++
34167 +++ killed by SIGKILL +++
34163 +++ killed by SIGKILL +++
34177 +++ killed by SIGKILL +++
34174 +++ killed by SIGKILL +++
34170 +++ killed by SIGKILL +++
34169 +++ killed by SIGKILL +++
34168 +++ killed by SIGKILL +++
34165 +++ killed by SIGKILL +++
34164 +++ killed by SIGKILL +++
34162 +++ killed by SIGKILL +++
34161 +++ killed by SIGKILL +++
34160 +++ killed by SIGKILL +++
34158 +++ killed by SIGKILL +++
34166 +++ killed by SIGKILL +++
34154 +++ killed by SIGKILL +++

@rgrannell1
Copy link
Author

rgrannell1 commented Mar 16, 2025

Image

It looks like a (53GB!) memory leak in bumpalo::Bump::new_chunk and bumpalo::Bump::alloc_layout_slow

Image

and a standard flamechart

Image

I know nothing about Rust (I just write typescript) so this is probably as much as I can figure out. Let me know if I can give more specifics!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deno fmt Related to the "deno fmt" subcommand or dprint
Projects
None yet
Development

No branches or pull requests

2 participants