Skip to content

Conversation

@ax3l
Copy link
Contributor

@ax3l ax3l commented Jul 7, 2025

Summary

Seeking help for the issue in #2367 by providing these unit tests as part of check-enzyme-integration-reverse.

This test demonstrates two issues with std::unordered_map:

  • operator[] has a memory leak/double free
  • at() fails to compile
Compile Warnings & Error
freeing without malloc   %46 = load ptr, ptr %0, align 8, !tbaa !23
freeing without malloc   %46 = load ptr, ptr %0, align 8, !tbaa !23
freeing without malloc   %15 = load ptr, ptr %malloccall, align 8, !tbaa !24
freeing without malloc   %28 = load ptr, ptr %malloccall1, align 8, !tbaa !24
freeing without malloc   %15 = load ptr, ptr %malloccall, align 8, !tbaa !24
freeing without malloc   %28 = load ptr, ptr %malloccall1, align 8, !tbaa !24
freeing without malloc   %11 = load ptr, ptr %3, align 8, !tbaa !16
freeing without malloc   %25 = load ptr, ptr %24, align 8, !tbaa !16
freeing without malloc   %22 = phi ptr [ %23, %33 ], [ %19, %.preheader ]
freeing without malloc   %40 = load ptr, ptr %2, align 8, !tbaa !26
error: <unknown>:0:0: in function preprocess__Z15compute_umap_atd double (double): Enzyme: Cannot deduce type of copy   call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(7) %6, ptr noundef nonnull align 1 dereferenceable(7) @.str, i64 7, i1 false) #21

To Do

Please feel free to push to this PR as needed 🙏 I will also try to mingle around with it a bit, but am still very early in understanding what's going on :)

  • add fix for memory leak/double free in operator[]
  • add fix for compile issue with at()

@ax3l ax3l force-pushed the test-umap-memory-leak-at branch 2 times, most recently from cde4331 to 57872dd Compare July 7, 2025 18:56
@ax3l ax3l force-pushed the test-umap-memory-leak-at branch from 57872dd to 1c76818 Compare July 7, 2025 19:12
This demonstrates two issues with `std::unordered_map`:
- `at()` fails to compile
- `operator[]` has a memory leak
@ax3l ax3l force-pushed the test-umap-memory-leak-at branch from 1c76818 to 0794e81 Compare July 7, 2025 19:25
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.

1 participant