Skip to content

Arena-ified binary-trees benchmark causes memory corruption and crashes #2065

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

Closed
pcwalton opened this issue Mar 28, 2012 · 1 comment
Closed
Labels
A-lifetimes Area: Lifetimes / regions I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.

Comments

@pcwalton
Copy link
Contributor

Converting shootout-binarytrees.rs to use arenas here: https://gist.github.com/2231052

Crashes with these valgrind errors:

==49019== Memcheck, a memory error detector
==49019== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==49019== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==49019== Command: ./shootout-binarytrees 0
==49019== 
--49019-- /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib:
--49019-- dSYM directory is missing; consider using --dsymutil=yes
==49019== Thread 2:
==49019== Invalid write of size 8
==49019==    at 0x100000E5A: bottom_up_tree::_e63043ce7b6977c5 (in ./shootout-binarytrees)
==49019==    by 0x100000D87: bottom_up_tree::_e63043ce7b6977c5 (in ./shootout-binarytrees)
==49019==    by 0x100000DCB: bottom_up_tree::_e63043ce7b6977c5 (in ./shootout-binarytrees)
==49019==    by 0x100000D87: bottom_up_tree::_e63043ce7b6977c5 (in ./shootout-binarytrees)
==49019==    by 0x1000025E8: __morestack (in ./shootout-binarytrees)
==49019==  Address 0x101f0c4b0 is 22,256 bytes inside a block of size 23,600 alloc'd
==49019==    at 0x100013829: malloc (vg_replace_malloc.c:266)
==49019==    by 0x10065393E: rust_srv::malloc(unsigned long) (in /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib)
==49019==    by 0x10066D0D4: memory_region::malloc(unsigned long, char const*, bool) (in /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib)
==49019==    by 0x10064CD4E: create_stack(memory_region*, unsigned long) (in /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib)
==49019==    by 0x10064B422: rust_task::new_stack(unsigned long) (in /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib)
==49019==    by 0x10064B5A0: new_stack_slow(new_stack_args*) (in /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib)
==49019==    by 0x10066E0D6: __morestack (in /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib)
==49019== 
==49019== Invalid write of size 8
==49019==    at 0x100000E5E: bottom_up_tree::_e63043ce7b6977c5 (in ./shootout-binarytrees)
==49019==    by 0x100000D87: bottom_up_tree::_e63043ce7b6977c5 (in ./shootout-binarytrees)
==49019==    by 0x100000DCB: bottom_up_tree::_e63043ce7b6977c5 (in ./shootout-binarytrees)
==49019==    by 0x100000D87: bottom_up_tree::_e63043ce7b6977c5 (in ./shootout-binarytrees)
==49019==    by 0x1000025E8: __morestack (in ./shootout-binarytrees)
==49019==  Address 0x101f0c4a8 is 22,248 bytes inside a block of size 23,600 alloc'd
==49019==    at 0x100013829: malloc (vg_replace_malloc.c:266)
==49019==    by 0x10065393E: rust_srv::malloc(unsigned long) (in /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib)
==49019==    by 0x10066D0D4: memory_region::malloc(unsigned long, char const*, bool) (in /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib)
==49019==    by 0x10064CD4E: create_stack(memory_region*, unsigned long) (in /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib)
==49019==    by 0x10064B422: rust_task::new_stack(unsigned long) (in /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib)
==49019==    by 0x10064B5A0: new_stack_slow(new_stack_args*) (in /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib)
==49019==    by 0x10066E0D6: __morestack (in /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib)
==49019== 
==49019== Invalid write of size 8
==49019==    at 0x100000E62: bottom_up_tree::_e63043ce7b6977c5 (in ./shootout-binarytrees)
==49019==    by 0x100000D87: bottom_up_tree::_e63043ce7b6977c5 (in ./shootout-binarytrees)
==49019==    by 0x100000DCB: bottom_up_tree::_e63043ce7b6977c5 (in ./shootout-binarytrees)
==49019==    by 0x100000D87: bottom_up_tree::_e63043ce7b6977c5 (in ./shootout-binarytrees)
==49019==    by 0x1000025E8: __morestack (in ./shootout-binarytrees)
==49019==  Address 0x101f0c4a0 is 22,240 bytes inside a block of size 23,600 alloc'd
==49019==    at 0x100013829: malloc (vg_replace_malloc.c:266)
==49019==    by 0x10065393E: rust_srv::malloc(unsigned long) (in /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib)
==49019==    by 0x10066D0D4: memory_region::malloc(unsigned long, char const*, bool) (in /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib)
==49019==    by 0x10064CD4E: create_stack(memory_region*, unsigned long) (in /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib)
==49019==    by 0x10064B422: rust_task::new_stack(unsigned long) (in /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib)
==49019==    by 0x10064B5A0: new_stack_slow(new_stack_args*) (in /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib)
==49019==    by 0x10066E0D6: __morestack (in /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib)
==49019== 
==49019== Invalid write of size 8
==49019==    at 0x100000E66: bottom_up_tree::_e63043ce7b6977c5 (in ./shootout-binarytrees)
==49019==    by 0x100000D87: bottom_up_tree::_e63043ce7b6977c5 (in ./shootout-binarytrees)
==49019==    by 0x100000DCB: bottom_up_tree::_e63043ce7b6977c5 (in ./shootout-binarytrees)
==49019==    by 0x100000D87: bottom_up_tree::_e63043ce7b6977c5 (in ./shootout-binarytrees)
==49019==    by 0x1000025E8: __morestack (in ./shootout-binarytrees)
==49019==  Address 0x101f0c498 is 22,232 bytes inside a block of size 23,600 alloc'd
==49019==    at 0x100013829: malloc (vg_replace_malloc.c:266)
==49019==    by 0x10065393E: rust_srv::malloc(unsigned long) (in /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib)
==49019==    by 0x10066D0D4: memory_region::malloc(unsigned long, char const*, bool) (in /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib)
==49019==    by 0x10064CD4E: create_stack(memory_region*, unsigned long) (in /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib)
==49019==    by 0x10064B422: rust_task::new_stack(unsigned long) (in /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib)
==49019==    by 0x10064B5A0: new_stack_slow(new_stack_args*) (in /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib)
==49019==    by 0x10066E0D6: __morestack (in /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib)
==49019== 
==49019== Invalid write of size 8
==49019==    at 0x100000E5A: bottom_up_tree::_e63043ce7b6977c5 (in ./shootout-binarytrees)
==49019==    by 0x100000DCB: bottom_up_tree::_e63043ce7b6977c5 (in ./shootout-binarytrees)
==49019==    by 0x100000DCB: bottom_up_tree::_e63043ce7b6977c5 (in ./shootout-binarytrees)
==49019==    by 0x100000D87: bottom_up_tree::_e63043ce7b6977c5 (in ./shootout-binarytrees)
==49019==    by 0x1000025E8: __morestack (in ./shootout-binarytrees)
==49019==  Address 0x101f0c5b0 is 22,512 bytes inside a block of size 23,600 alloc'd
==49019==    at 0x100013829: malloc (vg_replace_malloc.c:266)
==49019==    by 0x10065393E: rust_srv::malloc(unsigned long) (in /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib)
==49019==    by 0x10066D0D4: memory_region::malloc(unsigned long, char const*, bool) (in /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib)
==49019==    by 0x10064CD4E: create_stack(memory_region*, unsigned long) (in /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib)
==49019==    by 0x10064B422: rust_task::new_stack(unsigned long) (in /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib)
==49019==    by 0x10064B5A0: new_stack_slow(new_stack_args*) (in /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib)
==49019==    by 0x10066E0D6: __morestack (in /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib)
==49019== 
==49019== Invalid write of size 8
==49019==    at 0x100000E5E: bottom_up_tree::_e63043ce7b6977c5 (in ./shootout-binarytrees)
==49019==    by 0x100000DCB: bottom_up_tree::_e63043ce7b6977c5 (in ./shootout-binarytrees)
==49019==    by 0x100000DCB: bottom_up_tree::_e63043ce7b6977c5 (in ./shootout-binarytrees)
==49019==    by 0x100000D87: bottom_up_tree::_e63043ce7b6977c5 (in ./shootout-binarytrees)
==49019==    by 0x1000025E8: __morestack (in ./shootout-binarytrees)
==49019==  Address 0x101f0c5a8 is 22,504 bytes inside a block of size 23,600 alloc'd
==49019==    at 0x100013829: malloc (vg_replace_malloc.c:266)
==49019==    by 0x10065393E: rust_srv::malloc(unsigned long) (in /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib)
==49019==    by 0x10066D0D4: memory_region::malloc(unsigned long, char const*, bool) (in /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib)
==49019==    by 0x10064CD4E: create_stack(memory_region*, unsigned long) (in /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib)
==49019==    by 0x10064B422: rust_task::new_stack(unsigned long) (in /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib)
==49019==    by 0x10064B5A0: new_stack_slow(new_stack_args*) (in /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib)
==49019==    by 0x10066E0D6: __morestack (in /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib)
==49019== 
==49019== Invalid write of size 8
==49019==    at 0x100000E62: bottom_up_tree::_e63043ce7b6977c5 (in ./shootout-binarytrees)
==49019==    by 0x100000DCB: bottom_up_tree::_e63043ce7b6977c5 (in ./shootout-binarytrees)
==49019==    by 0x100000DCB: bottom_up_tree::_e63043ce7b6977c5 (in ./shootout-binarytrees)
==49019==    by 0x100000D87: bottom_up_tree::_e63043ce7b6977c5 (in ./shootout-binarytrees)
==49019==    by 0x1000025E8: __morestack (in ./shootout-binarytrees)
==49019==  Address 0x101f0c5a0 is 22,496 bytes inside a block of size 23,600 alloc'd
==49019==    at 0x100013829: malloc (vg_replace_malloc.c:266)
==49019==    by 0x10065393E: rust_srv::malloc(unsigned long) (in /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib)
==49019==    by 0x10066D0D4: memory_region::malloc(unsigned long, char const*, bool) (in /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib)
==49019==    by 0x10064CD4E: create_stack(memory_region*, unsigned long) (in /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib)
==49019==    by 0x10064B422: rust_task::new_stack(unsigned long) (in /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib)
==49019==    by 0x10064B5A0: new_stack_slow(new_stack_args*) (in /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib)
==49019==    by 0x10066E0D6: __morestack (in /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib)
==49019== 
==49019== Invalid write of size 8
==49019==    at 0x100000E66: bottom_up_tree::_e63043ce7b6977c5 (in ./shootout-binarytrees)
==49019==    by 0x100000DCB: bottom_up_tree::_e63043ce7b6977c5 (in ./shootout-binarytrees)
==49019==    by 0x100000DCB: bottom_up_tree::_e63043ce7b6977c5 (in ./shootout-binarytrees)
==49019==    by 0x100000D87: bottom_up_tree::_e63043ce7b6977c5 (in ./shootout-binarytrees)
==49019==    by 0x1000025E8: __morestack (in ./shootout-binarytrees)
==49019==  Address 0x101f0c598 is 22,488 bytes inside a block of size 23,600 alloc'd
==49019==    at 0x100013829: malloc (vg_replace_malloc.c:266)
==49019==    by 0x10065393E: rust_srv::malloc(unsigned long) (in /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib)
==49019==    by 0x10066D0D4: memory_region::malloc(unsigned long, char const*, bool) (in /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib)
==49019==    by 0x10064CD4E: create_stack(memory_region*, unsigned long) (in /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib)
==49019==    by 0x10064B422: rust_task::new_stack(unsigned long) (in /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib)
==49019==    by 0x10064B5A0: new_stack_slow(new_stack_args*) (in /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib)
==49019==    by 0x10066E0D6: __morestack (in /Users/pwalton/Source/rust/master/build/x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/librustrt.dylib)
==49019== 
==49019== Invalid write of size 8
==49019==    at 0x100000E14: bottom_up_tree::_e63043ce7b6977c5 (in ./shootout-binarytrees)
==49019==    by 0x100000D87: bottom_up_tree::_e63043ce7b6977c5 (in ./shootout-binarytrees)
==49019==    by 0x100000DCB: bottom_up_tree::_e63043ce7b6977c5 (in ./shootout-binarytrees)
==49019==    by 0x1000025E8: __morestack (in ./shootout-binarytrees)
==49019==  Address 0x1 is not stack'd, malloc'd or (recently) free'd
==49019== 
==49019== 
==49019== Process terminating with default action of signal 11 (SIGSEGV)
==49019==  Access not within mapped region at address 0x1
==49019==    at 0x100000E14: bottom_up_tree::_e63043ce7b6977c5 (in ./shootout-binarytrees)
==49019==    by 0x100000D87: bottom_up_tree::_e63043ce7b6977c5 (in ./shootout-binarytrees)
==49019==    by 0x100000DCB: bottom_up_tree::_e63043ce7b6977c5 (in ./shootout-binarytrees)
==49019==    by 0x1000025E8: __morestack (in ./shootout-binarytrees)
==49019==  If you believe this happened as a result of a stack
==49019==  overflow in your program's main thread (unlikely but
==49019==  possible), you can try to increase the size of the
==49019==  main thread stack using the --main-stacksize= flag.
==49019==  The main thread stack size used in this run was 8388608.
==49019== 
==49019== HEAP SUMMARY:
==49019==     in use at exit: 21,371,407 bytes in 593 blocks
==49019==   total heap usage: 748 allocs, 155 frees, 21,385,686 bytes allocated
==49019== 
==49019== LEAK SUMMARY:
==49019==    definitely lost: 0 bytes in 0 blocks
==49019==    indirectly lost: 0 bytes in 0 blocks
==49019==      possibly lost: 0 bytes in 0 blocks
==49019==    still reachable: 21,371,319 bytes in 592 blocks
==49019==         suppressed: 88 bytes in 1 blocks
==49019== Rerun with --leak-check=full to see details of leaked memory
==49019== 
==49019== For counts of detected and suppressed errors, rerun with: -v
==49019== ERROR SUMMARY: 9 errors from 9 contexts (suppressed: 0 from 0)
@pcwalton
Copy link
Contributor Author

pcwalton commented Apr 1, 2012

Fixed.

@pcwalton pcwalton closed this as completed Apr 1, 2012
celinval added a commit to celinval/rust-dev that referenced this issue Jun 4, 2024
Filter roots to only collect public functions. Also, make the collection function more robust and to account for associated functions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lifetimes Area: Lifetimes / regions I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.
Projects
None yet
Development

No branches or pull requests

1 participant