-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
run-pass/coerce-expected-unsized.rs : jemalloc aborts in enable-debug builds #36278
Comments
I didn't fully check the validity of the rest of the code, I thought it was correct modulo initial starting data. |
Stepping through a variant of the code, I'm certainly observing a discrepancy where we pass a small size to allocate and a larger size to deallocate. |
Code: https://is.gd/3BpBuR some data from
In particular, the input to |
(note that the code I posted is not printing the actually relevant sizes, since it seems to me like our issue is with the size of the array in the After fixing that, Not sure yet where the 136 is coming from; perhaps we are adding another 8 somewhere? |
On the other hand, manually breaking on Here's the LLVM IR for the generated code for that routine:
(I haven't yet validated where its getting 8 and 24 from in that computation, but if nothing else:
|
Hmm maybe we are double-counting the |
In particular, this line where we recurse: let last_field = def.struct_variant().fields.last().unwrap();
let field_ty = monomorphize::field_ty(bcx.tcx(), substs, last_field);
let (unsized_size, unsized_align) = size_and_align_of_dst(bcx, field_ty, info); that is recurring on the last field that is immediately present in the struct, causing us to add 8. But the already computed prefix size (24 in this case) actually includes the prefix that is in that last field, I think |
@pnkfelix Does Come to think of it, is this because let fields = variant.offset_after_field.len();
if fields >= 2 {
variant.offset_after_field[fields - 2].bytes()
} else {
0
} |
@eddyb yeah that sounds promising (that is, to not use Update: Initial results look good, at least in terms of fixing this particular bug. |
…eddyb When sizing DST, don't double-count nested struct prefixes. When computing size of `struct P<T>(Q<T>)`, don't double-count prefix added by `Q` Fix rust-lang#36278. Fix rust-lang#36294.
Configure flags (I suspect
--enable-debug
is the only relevant one, though of course I recommend passing--enable-optimize
for bootstrapping):Steps to reproduce:
The text was updated successfully, but these errors were encountered: