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

block as a class leads to segfaults #2584

Closed
eholk opened this issue Jun 13, 2012 · 6 comments
Closed

block as a class leads to segfaults #2584

eholk opened this issue Jun 13, 2012 · 6 comments
Labels
A-codegen Area: Code generation I-crash Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.
Milestone

Comments

@eholk
Copy link
Contributor

eholk commented Jun 13, 2012

The recent change seems to make it possible to end up with one of the block fields being a null pointer. A patch that exposes this behavior is available at https://gist.github.com/2925753

@ghost ghost assigned catamorphism Jun 13, 2012
@eholk
Copy link
Contributor Author

eholk commented Jun 14, 2012

Here's a backtrace:

[host-5-154:build eholk]$ gdb --args x86_64-apple-darwin/stage1/bin/rustc --cfg stage1  -O --target=x86_64-apple-darwin -o x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/libcore.dylib /Users/eholk/Documents/projects/mozilla/rust/src/libcore/core.rc
GNU gdb 6.3.50-20050815 (Apple version gdb-1705) (Fri Jul  1 10:50:06 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin"...Reading symbols for shared libraries .. done

(gdb) r
Starting program: /Users/eholk/Documents/projects/mozilla/rust/build/x86_64-apple-darwin/stage1/bin/rustc --cfg stage1 -O --target=x86_64-apple-darwin -o x86_64-apple-darwin/stage1/lib/rustc/x86_64-apple-darwin/lib/libcore.dylib /Users/eholk/Documents/projects/mozilla/rust/src/libcore/core.rc
Reading symbols for shared libraries .....+................................................................. done

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x00000000000000a8
[Switching to process 56322 thread 0x1e03]
0x0000000100cbd9c3 in middle::trans::base::bcx_icx::meth2293::insn_ctxt::_3e984ab9a2e9bf70::_02 ()
(gdb) bt
#0  0x0000000100cbd9c3 in middle::trans::base::bcx_icx::meth2293::insn_ctxt::_3e984ab9a2e9bf70::_02 ()
#1  0x000000010107a1ae in str2622 ()
#2  0x0000000100cdf5b2 in middle::trans::base::move_val::_dd8bbd759ed35a3d::_02 ()
#3  0x0000000100ce72b1 in middle::trans::base::trans_assign_op::_dcbae8ce5868daa8::_02 ()
#4  0x0000000100d1d1fb in middle::trans::base::trans_expr::unrooted::_e05f72d83f6e492c::_02 ()
#5  0x0000000100ce3e51 in middle::trans::base::trans_expr::_e05f72d83f6e492c::_02 ()
#6  0x0000000100d23b65 in middle::trans::base::trans_stmt::_17322c3f90f22da6::_02 ()
#7  0x0000000100cee351 in middle::trans::base::trans_block::_e3aa2aeff1a48c5c::_02 ()
#8  0x0000000100ceec75 in middle::trans::base::trans_while::_9effb9d55ffc7be5::_02 ()
#9  0x0000000100d1cda6 in middle::trans::base::trans_expr::unrooted::_e05f72d83f6e492c::_02 ()
#10 0x0000000101029804 in __morestack ()
Previous frame inner to this frame (gdb could not unwind past this frame)
(gdb) 

This branch should have exactly the code to make this happen on a Mac: https://github.com/eholk/rust/commits/issue-2548

@catamorphism
Copy link
Contributor

See #2633 for the root cause of this problem. There are at least two possible easy workarounds, though: change move_val not to take an lval_result (it doesn't actually use the bcx field in its lval_result argument), and just take the kind and val as separate arguments; or make move_val's block argument pass-by-copy. I'm implementing one of these. Or if you get impatient, @eholk , you should be able to do the same in your local branch :-)

@eholk
Copy link
Contributor Author

eholk commented Jun 16, 2012

Thanks for tracking this down!

@catamorphism
Copy link
Contributor

It was a fun one (though it turned out to not really be about classes at all!)

@catamorphism
Copy link
Contributor

@eholk If you rebase your branch against incoming, a14df27 should fix the segfault. I'm closing this for now, but reopen if it doesn't work.

@eholk
Copy link
Contributor Author

eholk commented Jun 18, 2012

That seems to fix the problem, but since the segfault is in rustc, we are unfortunately going to need a snapshot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation 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

2 participants