My program segfaults and/or aborts when I abuse generic_associated_types #71210
Labels
A-GATs
Area: Generic associated types (GATs)
C-bug
Category: This is a bug.
F-generic_associated_types
`#![feature(generic_associated_types)]` a.k.a. GATs
I-unsound
Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness
requires-nightly
This issue requires a nightly compiler in some way.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
I tried this code:
(See also https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=05e8a880961163a517c92515c4edff7d)
When I feed this
main.rs
intorustc
it happily gives me amain
program. When I run saidmain
program, I get[1] 32118 segmentation fault (core dumped) RUST_BACKTRACE=1 ./main
fromzsh
. (Themain
program also segfaults withoutRUST_BACKTRACE=1
.)Instead, I expected the compiler to reject my program with a type error: The
HashMap
iterator hasSelf::Item = (&'a K, &'a V)
which is not aResult<Box<u8>, Papadimoulian>
—yet if my program is to mean what I think it should mean, it's claiming that to be the case.If I compile without
--release
and remove a dash from the unused string, I instead getmunmap_chunk(): invalid pointer
. If I remove all the dashes, or I remove the unused variable alltogether (and still compile without--release
), I getfree(): invalid pointer
.If I change
Box<u8>
toBox<()>
I get a test success.If I keep
Box<u8>
and replacePapadimoulian
withOption<()>
I get a segfault. I also get segfaults if I replacePapadimoulian
withbool
oru8
, but not if I replace it with()
(in all cases keepingBox<u8>
.)These two issues seem to be exploring the same feature, but with different results: #69184 and #67089.
The text was updated successfully, but these errors were encountered: