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

Print more informative message and backtrace on out of memory error #4604

Merged
merged 4 commits into from
Feb 12, 2025

Conversation

dipinhora
Copy link
Contributor

@dipinhora dipinhora commented Feb 6, 2025

Before:

out of memory: Cannot allocate memory

After:

out of memory trying to allocate 18446744073709551615 bytes: Cannot allocate memory
/workspaces/ponyc/src/libponyrt/mem/alloc.c:53: ponyint_virt_alloc: Assertion `bytes < 0` failed.

Backtrace:
  ./ponyc(ponyint_assert_fail+0xb8) [0xc4de3bb213d4]
  ./ponyc(ponyint_virt_alloc+0xcc) [0xc4de3bb2d30c]
  ./ponyc(+0x20a1c) [0xc4de3bb20a1c]
  ./ponyc(+0x20198) [0xc4de3bb20198]
  ./ponyc(ponyint_pool_alloc_size+0x50) [0xc4de3bb2009c]
  ./ponyc(ponyint_heap_alloc_large+0x2d8) [0xc4de3bb1d1d0]
  ./ponyc(ponyint_heap_alloc+0xcc) [0xc4de3bb1cc00]
  ./ponyc(pony_alloc+0x74) [0xc4de3bb13044]
  ./ponyc(Pointer_U8_val_ref__alloc_Zo+0x14) [0xc4de3bb107b0]
  ./ponyc(String_ref_create_Zo+0x40) [0xc4de3bb0f3e4]
  ./ponyc(String_val_repeat_str_Zoo+0x6c) [0xc4de3bb0efd8]
  ./ponyc(String_val_mul_Zo+0x18) [0xc4de3bb0f0ec]
  ./ponyc(Main_tag_create_oo+0x38) [0xc4de3bb0eccc]
  ./ponyc(Main_Dispatch+0x44) [0xc4de3bb0e34c]
  ./ponyc(+0x12100) [0xc4de3bb12100]
  ./ponyc(ponyint_actor_run+0xe4) [0xc4de3bb116c8]
  ./ponyc(+0x231e4) [0xc4de3bb231e4]
  ./ponyc(+0x22438) [0xc4de3bb22438]
  /lib/aarch64-linux-gnu/libc.so.6(+0x8597c) [0xec2b035d597c]
  /lib/aarch64-linux-gnu/libc.so.6(+0xeba4c) [0xec2b0363ba4c]
Aborted

@ponylang-main ponylang-main added the discuss during sync Should be discussed during an upcoming sync label Feb 6, 2025
perror("out of memory: ");
abort();
fprintf(stderr, "out of memory trying to allocate %zu bytes: %s\n", bytes, strerror(errno));
pony_assert(0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pony_assert will only run when debug otherwise it is a no-op. You should add an abort after so that for non-release, the abort will be called.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

src/libponyrt/mem/alloc.c Outdated Show resolved Hide resolved
@SeanTAllen SeanTAllen removed the discuss during sync Should be discussed during an upcoming sync label Feb 11, 2025
@SeanTAllen SeanTAllen merged commit c7d1b70 into ponylang:main Feb 12, 2025
22 checks passed
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

Successfully merging this pull request may close these issues.

4 participants