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

regression: unexpected unsized tail ICE #123275

Closed
Mark-Simulacrum opened this issue Mar 31, 2024 · 9 comments · Fixed by #123578
Closed

regression: unexpected unsized tail ICE #123275

Mark-Simulacrum opened this issue Mar 31, 2024 · 9 comments · Fixed by #123578
Assignees
Labels
E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Milestone

Comments

@Mark-Simulacrum
Copy link
Member

[INFO] [stdout] error: internal compiler error: compiler/rustc_monomorphize/src/collector.rs:1121:22: unexpected unsized tail: hyper::server::server::new_svc::State<hyper::server::conn::AddrStream, futures::future::Ready<std::result::Result<warp::filter::service::FilteredService<warp::trace::internal::WithTrace<Closure(DefId(57:1400 ~ warp[b780]::filters::trace::request::{closure#0}), [i8, Binder(extern "RustCall" fn((warp::trace::Info<ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon })>,)) -> tracing::span::Span, [Region(BrAnon)]), ()]), warp::filter::map::Map<warp::filter::FilterFn<Closure(DefId(57:1165 ~ warp[b780]::filters::path::end::{closure#0}), [i8, Binder(extern "RustCall" fn((&ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) mut warp::route::Route,)) -> futures::future::Ready<std::result::Result<(), warp::Rejection>>, [Region(BrAnon)]), ()])>, Closure(DefId(0:9 ~ rustc_warp_ice[7eee]::main::{closure#0}), [i8, Binder(extern "RustCall" fn(()) -> &ReErased str, []), ()])>>>, std::convert::Infallible>>, warp::filter::service::FilteredService<warp::trace::internal::WithTrace<Closure(DefId(57:1400 ~ warp[b780]::filters::trace::request::{closure#0}), [i8, Binder(extern "RustCall" fn((warp::trace::Info<ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon })>,)) -> tracing::span::Span, [Region(BrAnon)]), ()]), warp::filter::map::Map<warp::filter::FilterFn<Closure(DefId(57:1165 ~ warp[b780]::filters::path::end::{closure#0}), [i8, Binder(extern "RustCall" fn((&ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) mut warp::route::Route,)) -> futures::future::Ready<std::result::Result<(), warp::Rejection>>, [Region(BrAnon)]), ()])>, Closure(DefId(0:9 ~ rustc_warp_ice[7eee]::main::{closure#0}), [i8, Binder(extern "RustCall" fn(()) -> &ReErased str, []), ()])>>>, hyper::common::exec::Exec, hyper::server::server::NoopWatcher>

This seems like a potential recurrence of #108721, which was fixed in #108754 but lacked a test case.

@Mark-Simulacrum Mark-Simulacrum added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. regression-from-stable-to-beta Performance or correctness regression from stable to beta. labels Mar 31, 2024
@Mark-Simulacrum Mark-Simulacrum added this to the 1.78.0 milestone Mar 31, 2024
@rustbot rustbot added I-prioritize Issue: Indicates that prioritization has been requested for this issue. needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Mar 31, 2024
@compiler-errors
Copy link
Member

searched nightlies: from nightly-2024-02-01 to nightly-2024-02-29
regressed nightly: nightly-2024-02-20
searched commit range: 2bf78d1...3246e79
regressed commit: 0243834

bisected with cargo-bisect-rustc v0.6.8

Host triple: x86_64-unknown-linux-gnu
Reproduce with:

cargo bisect-rustc --start=2024-02-01 --end=2024-02-29 --regress=ice 

Regressed in #120463 -- cc @lcnr

@compiler-errors compiler-errors added the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Mar 31, 2024
@apiraino
Copy link
Contributor

apiraino commented Apr 2, 2024

WG-prioritization assigning priority (Zulip discussion).

@rustbot label -I-prioritize +P-high

@rustbot rustbot added P-high High priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Apr 2, 2024
@lcnr
Copy link
Contributor

lcnr commented Apr 2, 2024

can revert the change from #120463 which caused this 2 weeks before this hits stable. We dshould really get a minimization of this issue though :/

@lcnr
Copy link
Contributor

lcnr commented Apr 2, 2024

(the cause should be this commit 399a258)

@wesleywiser wesleywiser self-assigned this Apr 4, 2024
@lqd
Copy link
Member

lqd commented Apr 4, 2024

Interestingly, this builds on nightly. It seems to me that #122493 has fixed, or hid, the ICE 🤔.

@compiler-errors
Copy link
Member

Probably hidden; that's why we need an MCVE. If it has to do w/ a field not in a struct tail, a simple reordering of fields may trigger this bug again.

@lqd
Copy link
Member

lqd commented Apr 6, 2024

I'm not sure how small we can make it, but I've reduced this to a more reasonable size. I've ran out of steam on this if someone wants to help it cross the finish line if needed.

It's still very convoluted, and more layers could be removed. It's quite fiddly though, removing a Send bound here or there makes the ICE disappear like a frightened turtle.

The ICE is still present on nightly, but I lost track of the actual source while reducing hyper: it used to happen in the collector but now a bit later. I hope it's fine, it's still in codegen and bisects to #120463 as well.

This is not a place of honor
use std::future::Future;
trait TryFuture: Future {
    type Ok;
}
impl<F, T> TryFuture for F
where
    F: ?Sized + Future<Output = Option<T>>,
{
    type Ok = T;
}
trait Executor {}
struct Exec {}
trait HttpBody {
    type Data;
}
trait ConnStreamExec<F> {}
impl<F> ConnStreamExec<F> for Exec where H2Stream<F>: Send {}
impl<E, F> ConnStreamExec<F> for E where E: Executor {}
struct H2Stream<F> {
    _fut: F,
}
trait NewSvcExec<S, E, W: Watcher<S, E>> {
    fn execute_new_svc(&mut self, _fut: NewSvcTask<S, E, W>) {
        unimplemented!()
    }
}
impl<S, E, W> NewSvcExec<S, E, W> for Exec where W: Watcher<S, E> {}
trait Watcher<S, E> {
    type Future;
}
struct NoopWatcher;
impl<S, E> Watcher<S, E> for NoopWatcher
where
    S: HttpService,
    E: ConnStreamExec<S::Future>,
{
    type Future = Option<<<S as HttpService>::ResBody as HttpBody>::Data>;
}
trait Service<Request> {
    type Response;
    type Future;
}
trait HttpService {
    type ResBody: HttpBody;
    type Future;
}
struct Body {}
impl HttpBody for Body {
    type Data = String;
}
impl<S> HttpService for S
where
    S: Service<(), Response = ()>,
{
    type ResBody = Body;
    type Future = S::Future;
}
trait MakeServiceRef<Target> {
    type ResBody;
    type Service: HttpService<ResBody = Self::ResBody>;
}
impl<T, Target, S, F> MakeServiceRef<Target> for T
where
    T: for<'a> Service<&'a Target, Response = S, Future = F>,
    S: HttpService,
{
    type Service = S;
    type ResBody = S::ResBody;
}
fn make_service_fn<F, Target, Ret>(_f: F) -> MakeServiceFn<F>
where
    F: FnMut(&Target) -> Ret,
    Ret: Future,
{
    unimplemented!()
}
struct MakeServiceFn<F> {
    _func: F,
}
impl<'t, F, Ret, Target, Svc> Service<&'t Target> for MakeServiceFn<F>
where
    F: FnMut(&Target) -> Ret,
    Ret: Future<Output = Option<Svc>>,
{
    type Response = Svc;
    type Future = Option<()>;
}
struct AddrIncoming {}
struct Server<I, S, E> {
    _incoming: I,
    _make_service: S,
    _protocol: E,
}
impl<I, S, E, B> Server<I, S, E>
where
    S: MakeServiceRef<(), ResBody = B>,
    B: HttpBody,
    E: ConnStreamExec<<S::Service as HttpService>::Future>,
    E: NewSvcExec<S::Service, E, NoopWatcher>,
{
    fn serve(&mut self) {
        let fut = NewSvcTask::new();
        self._protocol.execute_new_svc(fut);
    }
}
fn serve<S>(_make_service: S) -> Server<AddrIncoming, S, Exec> {
    unimplemented!()
}
struct NewSvcTask<S, E, W: Watcher<S, E>> {
    _state: State<S, E, W>,
}
struct State<S, E, W: Watcher<S, E>> {
    _fut: W::Future,
}
impl<S, E, W: Watcher<S, E>> NewSvcTask<S, E, W> {
    fn new() -> Self {
        unimplemented!()
    }
}
trait Filter {
    type Extract;
    type Future;
    fn map<F>(self, _fun: F) -> MapFilter<Self, F>
    where
        Self: Sized,
    {
        unimplemented!()
    }
    fn wrap_with<W>(self, _wrapper: W) -> W::Wrapped
    where
        Self: Sized,
        W: Wrap<Self>,
    {
        unimplemented!()
    }
}
fn service<F>(_filter: F) -> FilteredService<F>
where
    F: Filter,
{
    unimplemented!()
}
struct FilteredService<F> {
    _filter: F,
}
impl<F> Service<()> for FilteredService<F>
where
    F: Filter,
{
    type Response = ();
    type Future = FilteredFuture<F::Future>;
}
struct FilteredFuture<F> {
    _fut: F,
}
struct MapFilter<T, F> {
    _filter: T,
    _func: F,
}
impl<T, F> Filter for MapFilter<T, F>
where
    T: Filter,
    F: Func<T::Extract>,
{
    type Extract = F::Output;
    type Future = MapFilterFuture<T, F>;
}
struct MapFilterFuture<T: Filter, F> {
    _extract: T::Future,
    _func: F,
}
trait Wrap<F> {
    type Wrapped;
}
fn make_filter_fn<F, U>(_func: F) -> FilterFn<F>
where
    F: Fn() -> U,
{
    unimplemented!()
}
struct FilterFn<F> {
    _func: F,
}
impl<F, U> Filter for FilterFn<F>
where
    F: Fn() -> U,
    U: TryFuture,
    U::Ok: Send,
{
    type Extract = U::Ok;
    type Future = Option<U>;
}
fn trace<F>(_func: F) -> Trace<F>
where
    F: Fn(),
{
    unimplemented!()
}
struct Trace<F> {
    _func: F,
}
impl<FN, F> Wrap<F> for Trace<FN> {
    type Wrapped = WithTrace<FN, F>;
}
struct WithTrace<FN, F> {
    _filter: F,
    _trace: FN,
}
impl<FN, F> Filter for WithTrace<FN, F>
where
    F: Filter,
{
    type Extract = ();
    type Future = (F::Future, fn(F::Extract));
}
trait Func<Args> {
    type Output;
}
impl<F, R> Func<()> for F
where
    F: Fn() -> R,
{
    type Output = R;
}
fn main() {
    let make_service = make_service_fn(|_| {
        let tracer = trace(|| unimplemented!());
        let filter = make_filter_fn(|| std::future::ready(Some(())))
            .map(|| "Hello, world")
            .wrap_with(tracer);
        let svc = service(filter);
        std::future::ready(Some(svc))
    });
    let mut server = serve(make_service);
    server.serve();
}

@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 8, 2024
@bors bors closed this as completed in 984767e Apr 8, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Apr 8, 2024
Rollup merge of rust-lang#123578 - lqd:regression-123275, r=compiler-errors

Restore `pred_known_to_hold_modulo_regions`

As requested by `@lcnr` in rust-lang#123275 (comment) this PR restores `pred_known_to_hold_modulo_regions` to fix that "unexpected unsized tail" beta regression.

This also adds the reduced repro from rust-lang#123275 (comment) as a sub-optimal test is better than no test at all, and it'll also cover rust-lang#108721. It still ICEs on master, even though https://github.com/phlip9/rustc-warp-ice doesn't on nightly anymore, since rust-lang#122493.

Fixes rust-lang#123275.

r? `@compiler-errors` but feel free to close if you'd rather have a better test instead
cc `@wesleywiser` who had signed up to do the revert

Will need a backport if we go with this PR: `@rustbot` label +beta-nominated
@lqd
Copy link
Member

lqd commented Apr 8, 2024

Reopening to track beta backport.

@cuviper
Copy link
Member

cuviper commented Apr 12, 2024

Backported in #123801.

@cuviper cuviper closed this as completed Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants