Coder Social home page Coder Social logo

Comments (16)

jkelleyrtp avatar jkelleyrtp commented on May 10, 2024 1

I've uploaded jk/fix-ice which I think should address this bug.

Can you try changing your Dioxus dependency to

dioxus = { git = "https://github.com/DioxusLabs/dioxus", branch = "jk/fix-ice", features = [ "desktop"] }

This should remove the generics around AsRef - it makes the NodeFactory API slightly more cumbersome but I think should fix this issue.

from dioxus.

jkelleyrtp avatar jkelleyrtp commented on May 10, 2024 1

Closing this issue because we no longer cause an ICE, but looking at the other win issues.

from dioxus.

jkelleyrtp avatar jkelleyrtp commented on May 10, 2024

Hmm.... that's not good. I don't have a windows box but my version running on macOS checks just fine. Can you try checking the expansion too? I could release a patch that works around this bug, since given your stack trace I think I know where the ICE is coming from.

fn app(cx: Scope) -> Element {
    cx.render(LazyNodes::new_some(move |__cx: NodeFactory| -> VNode {
        use dioxus_elements::{GlobalAttributes, SvgAttributes};
        __cx.element(
            dioxus_elements::div,
            [],
            [],
            [__cx.text(format_args!("Hello, world!"))],
            None,
        )
    }))
}

from dioxus.

anderslanglands avatar anderslanglands commented on May 10, 2024

I get the same result with the expanded code:

thread 'rustc' panicked at 'assertion failed: !value.has_escaping_bound_vars()', /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\compiler\rustc_middle\src\ty\sty.rs:974:9
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.57.0 (f1edd0429 2021-11-29) running on x86_64-pc-windows-msvc

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 --crate-type lib

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [is_sized_raw] computing whether `[nodes::VNode<'_>]` is `Sized`
#1 [layout_of] computing layout of `&[nodes::VNode<'_>]`
#2 [layout_of] computing layout of `nodes::VFragment<'_>`
#3 [layout_of] computing layout of `nodes::VNode<'_>`
#4 [layout_of] computing layout of `core::option::Option<nodes::VNode<'_>>`
end of query stack
error: could not compile `dioxus-core`
warning: build failed, waiting for other jobs to finish...
error: build failed

from dioxus.

Patrick-Poitras avatar Patrick-Poitras commented on May 10, 2024

Can you try cargo clean then cargo build?

Edit: I have been able to replicate the bug compiling from scratch. Disregard the previous suggestion.

from dioxus.

Patrick-Poitras avatar Patrick-Poitras commented on May 10, 2024

For what it's worth, any code that has a dependency on dioxus seems to yield the same error, even with my main code being fn main(){}.

Something inside dioxus is causing the rust compiler to panic.

from dioxus.

Patrick-Poitras avatar Patrick-Poitras commented on May 10, 2024

@jkelleyrtp I'm trying (and failing) to create a minimally reproducible example for the rust compiler team. I see that the generics around AsRef seem to be the issue, so I'll check if that's in the known internal compiler errors repository.

from dioxus.

jkelleyrtp avatar jkelleyrtp commented on May 10, 2024

The core crate is pretty small, so maybe just comment out module by module until the culprit is found. I've trying to spin up a windows vm.

The LazyNodes module dances around sized/unsized types, try checking there? By getting rid of AsRef, I was able to shrink the error, so it might be in a handful of places.

from dioxus.

jkelleyrtp avatar jkelleyrtp commented on May 10, 2024

Looks like the bug is in LazyNodes. I use the same logic from https://docs.rs/stack_dst/latest/stack_dst/ - maybe they also cause an ICE. Found a simply workaround/fix, going to publish it. @anderslanglands @Patrick-Poitras

from dioxus.

Patrick-Poitras avatar Patrick-Poitras commented on May 10, 2024

I found a minimal example, it features the stuff from nodes and lazynodes.

use std::mem;
use std::marker::PhantomData;

struct LazyStack {}

impl Drop for LazyStack {
    fn drop(&mut self) {
        let g: *mut dyn FnMut(Option<NodeFactory<'_>>) -> Option<VNode<'_>> =
            unsafe {make_fat_ptr()};

        let clos = (unsafe { &mut *g });
        clos(None);
    }
}

unsafe fn make_fat_ptr<T: ?Sized>() -> *mut T {
    mem::MaybeUninit::<*mut T>::uninit().assume_init()
}

enum VNode<'src> {
    Fragment(&'src [VNode<'src>]),
}

struct NodeFactory<'a> {
    x : &'a PhantomData<u32>,
}

I don't know what simplified into mem::MaybeUninit::<*mut T>::uninit().assume_init(), but someone might want to have a look at that, it seems to me like that's a potential issue.

from dioxus.

jkelleyrtp avatar jkelleyrtp commented on May 10, 2024

The current version of Dioxus runs in my windows VM and has been pushed. Very interesting it triggered the ICE.

@Patrick-Poitras That's a pretty crazy set of incantations...

from dioxus.

anderslanglands avatar anderslanglands commented on May 10, 2024

@jkelleyrtp the `jk/fix-ice' branch does indeed fix the ICE but running the example gives me:

thread 'main' panicked at 'not implemented: path index.html/', C:\Users\ander\.cargo\git\checkouts\dioxus-1e619ce595d3799d\4ea5c99\packages\desktop\src\lib.rs:347:26
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\/library\std\src\panicking.rs:517
   1: core::panicking::panic_fmt
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\/library\core\src\panicking.rs:100
   2: dioxus_desktop::impl$0::new_window::closure$1
             at C:\Users\ander\.cargo\git\checkouts\dioxus-1e619ce595d3799d\4ea5c99\packages\desktop\src\lib.rs:347
   3: alloc::boxed::impl$46::call<tuple$<ref$<wry::shared::http::request::Request> >,dyn$<core::ops::function::Fn<tuple$<ref$<wry::shared::http::request::Request> >,assoc$<Output,enum$<core::result::Result<wry::shared::http::response::Response,enum$<wry::Error>
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\library\alloc\src\boxed.rs:1705
   4: wry::webview::webview2::impl$0::new::closure$0::closure$0::closure$4
             at C:\Users\ander\.cargo\registry\src\github.com-1ecc6299db9ec823\wry-0.12.2\src\webview\webview2\mod.rs:232
   5: webview2::impl$4::add_web_resource_requested::closure$0<wry::webview::webview2::impl$0::new::closure$0::closure$0::closure$4>
             at C:\Users\ander\.cargo\registry\src\github.com-1ecc6299db9ec823\webview2-0.1.4\src\lib.rs:1023
   6: alloc::boxed::impl$46::call<tuple$<ptr_mut$<ptr_mut$<webview2_sys::ICoreWebView2VTable> >,ptr_mut$<ptr_mut$<webview2_sys::ICoreWebView2WebResourceRequestedEventArgsVTable> > >,dyn$<core::ops::function::Fn<tuple$<ptr_mut$<ptr_mut$<webview2_sys::ICoreWebVie
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\library\alloc\src\boxed.rs:1705
   7: webview2::impl$4::add_web_resource_requested::impl$0::invoke::closure$0
             at C:\Users\ander\.cargo\registry\src\github.com-1ecc6299db9ec823\webview2-0.1.4\src\lib.rs:96
   8: core::ops::function::FnOnce::call_once<webview2::impl$4::add_web_resource_requested::impl$0::invoke::closure$0,tuple$<> >
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\library\core\src\ops\function.rs:227
   9: core::panic::unwind_safe::impl$23::call_once<i32,webview2::impl$4::add_web_resource_requested::impl$0::invoke::closure$0>
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\library\core\src\panic\unwind_safe.rs:271
  10: std::panicking::try::do_call<core::panic::unwind_safe::AssertUnwindSafe<webview2::impl$4::add_web_resource_requested::impl$0::invoke::closure$0>,i32>
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\library\std\src\panicking.rs:403
  11: std::panicking::begin_panic::impl$1::take_box<str>
  12: std::panicking::try<i32,core::panic::unwind_safe::AssertUnwindSafe<webview2::impl$4::add_web_resource_requested::impl$0::invoke::closure$0> >
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\library\std\src\panicking.rs:367
  13: std::panic::catch_unwind<core::panic::unwind_safe::AssertUnwindSafe<webview2::impl$4::add_web_resource_requested::impl$0::invoke::closure$0>,i32>
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\library\std\src\panic.rs:133
  14: webview2::impl$4::add_web_resource_requested::impl$0::invoke
             at C:\Users\ander\.cargo\registry\src\github.com-1ecc6299db9ec823\webview2-0.1.4\src\lib.rs:95
  15: webview2_sys::impl$329::vtable::icorewebview2webresourcerequestedeventhandler_invoke<webview2::impl$4::add_web_resource_requested::Impl,com::offset::Zero>
             at C:\Users\ander\.cargo\registry\src\github.com-1ecc6299db9ec823\webview2-sys-0.1.1\src\lib.rs:3178
  16: CreateWebViewEnvironmentWithOptionsInternal
  17: CreateWebViewEnvironmentWithOptionsInternal
  18: CreateWebViewEnvironmentWithOptionsInternal
  19: CreateWebViewEnvironmentWithOptionsInternal
  20: DllCanUnloadNow
  21: CreateWebViewEnvironmentWithOptionsInternal
  22: DllCanUnloadNow
  23: DllCanUnloadNow
  24: DllCanUnloadNow
  25: DllCanUnloadNow
  26: DllCanUnloadNow
  27: DllCanUnloadNow
  28: DllCanUnloadNow
  29: DllCanUnloadNow
  30: DllCanUnloadNow
  31: DllCanUnloadNow
  32: DllCanUnloadNow
  33: Ordinal0
  34: DllCanUnloadNow
  35: CallWindowProcW
  36: DispatchMessageW
  37: tao::platform_impl::platform::event_loop::EventLoop<enum$<dioxus_desktop::UserWindowEvent> >::run_return<enum$<dioxus_desktop::UserWindowEvent>,dioxus_desktop::launch_with_props::closure$0>
             at C:\Users\ander\.cargo\registry\src\github.com-1ecc6299db9ec823\tao-0.5.2\src\platform_impl\windows\event_loop.rs:248
  38: tao::platform_impl::platform::event_loop::EventLoop<enum$<dioxus_desktop::UserWindowEvent> >::run<enum$<dioxus_desktop::UserWindowEvent>,dioxus_desktop::launch_with_props::closure$0>
             at C:\Users\ander\.cargo\registry\src\github.com-1ecc6299db9ec823\tao-0.5.2\src\platform_impl\windows\event_loop.rs:203
  39: tao::event_loop::EventLoop<enum$<dioxus_desktop::UserWindowEvent> >::run<enum$<dioxus_desktop::UserWindowEvent>,dioxus_desktop::launch_with_props::closure$0>
             at C:\Users\ander\.cargo\registry\src\github.com-1ecc6299db9ec823\tao-0.5.2\src\event_loop.rs:151
  40: dioxus_desktop::launch_with_props<tuple$<>,dioxus_desktop::launch::closure$0>
             at C:\Users\ander\.cargo\git\checkouts\dioxus-1e619ce595d3799d\4ea5c99\packages\desktop\src\lib.rs:163
  41: dioxus_desktop::launch
             at C:\Users\ander\.cargo\git\checkouts\dioxus-1e619ce595d3799d\4ea5c99\packages\desktop\src\lib.rs:98
  42: hello_dioxus::main
             at .\src\main.rs:4
  43: core::ops::function::FnOnce::call_once<void (*)(),tuple$<> >
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\library\core\src\ops\function.rs:227
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
webview2: panic in callback function. Aborting because it's UB to unwind across FFI boundaries.
error: process didn't exit successfully: `target\debug\hello-dioxus.exe` (exit code: 0xc0000409, STATUS_STACK_BUFFER_OVERRUN)

from dioxus.

jkelleyrtp avatar jkelleyrtp commented on May 10, 2024

@jkelleyrtp the `jk/fix-ice' branch does indeed fix the ICE but running the example gives me:

thread 'main' panicked at 'not implemented: path index.html/', C:\Users\ander\.cargo\git\checkouts\dioxus-1e619ce595d3799d\4ea5c99\packages\desktop\src\lib.rs:347:26
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\/library\std\src\panicking.rs:517
   1: core::panicking::panic_fmt
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\/library\core\src\panicking.rs:100
   2: dioxus_desktop::impl$0::new_window::closure$1
             at C:\Users\ander\.cargo\git\checkouts\dioxus-1e619ce595d3799d\4ea5c99\packages\desktop\src\lib.rs:347
   3: alloc::boxed::impl$46::call<tuple$<ref$<wry::shared::http::request::Request> >,dyn$<core::ops::function::Fn<tuple$<ref$<wry::shared::http::request::Request> >,assoc$<Output,enum$<core::result::Result<wry::shared::http::response::Response,enum$<wry::Error>
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\library\alloc\src\boxed.rs:1705
   4: wry::webview::webview2::impl$0::new::closure$0::closure$0::closure$4
             at C:\Users\ander\.cargo\registry\src\github.com-1ecc6299db9ec823\wry-0.12.2\src\webview\webview2\mod.rs:232
   5: webview2::impl$4::add_web_resource_requested::closure$0<wry::webview::webview2::impl$0::new::closure$0::closure$0::closure$4>
             at C:\Users\ander\.cargo\registry\src\github.com-1ecc6299db9ec823\webview2-0.1.4\src\lib.rs:1023
   6: alloc::boxed::impl$46::call<tuple$<ptr_mut$<ptr_mut$<webview2_sys::ICoreWebView2VTable> >,ptr_mut$<ptr_mut$<webview2_sys::ICoreWebView2WebResourceRequestedEventArgsVTable> > >,dyn$<core::ops::function::Fn<tuple$<ptr_mut$<ptr_mut$<webview2_sys::ICoreWebVie
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\library\alloc\src\boxed.rs:1705
   7: webview2::impl$4::add_web_resource_requested::impl$0::invoke::closure$0
             at C:\Users\ander\.cargo\registry\src\github.com-1ecc6299db9ec823\webview2-0.1.4\src\lib.rs:96
   8: core::ops::function::FnOnce::call_once<webview2::impl$4::add_web_resource_requested::impl$0::invoke::closure$0,tuple$<> >
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\library\core\src\ops\function.rs:227
   9: core::panic::unwind_safe::impl$23::call_once<i32,webview2::impl$4::add_web_resource_requested::impl$0::invoke::closure$0>
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\library\core\src\panic\unwind_safe.rs:271
  10: std::panicking::try::do_call<core::panic::unwind_safe::AssertUnwindSafe<webview2::impl$4::add_web_resource_requested::impl$0::invoke::closure$0>,i32>
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\library\std\src\panicking.rs:403
  11: std::panicking::begin_panic::impl$1::take_box<str>
  12: std::panicking::try<i32,core::panic::unwind_safe::AssertUnwindSafe<webview2::impl$4::add_web_resource_requested::impl$0::invoke::closure$0> >
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\library\std\src\panicking.rs:367
  13: std::panic::catch_unwind<core::panic::unwind_safe::AssertUnwindSafe<webview2::impl$4::add_web_resource_requested::impl$0::invoke::closure$0>,i32>
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\library\std\src\panic.rs:133
  14: webview2::impl$4::add_web_resource_requested::impl$0::invoke
             at C:\Users\ander\.cargo\registry\src\github.com-1ecc6299db9ec823\webview2-0.1.4\src\lib.rs:95
  15: webview2_sys::impl$329::vtable::icorewebview2webresourcerequestedeventhandler_invoke<webview2::impl$4::add_web_resource_requested::Impl,com::offset::Zero>
             at C:\Users\ander\.cargo\registry\src\github.com-1ecc6299db9ec823\webview2-sys-0.1.1\src\lib.rs:3178
  16: CreateWebViewEnvironmentWithOptionsInternal
  17: CreateWebViewEnvironmentWithOptionsInternal
  18: CreateWebViewEnvironmentWithOptionsInternal
  19: CreateWebViewEnvironmentWithOptionsInternal
  20: DllCanUnloadNow
  21: CreateWebViewEnvironmentWithOptionsInternal
  22: DllCanUnloadNow
  23: DllCanUnloadNow
  24: DllCanUnloadNow
  25: DllCanUnloadNow
  26: DllCanUnloadNow
  27: DllCanUnloadNow
  28: DllCanUnloadNow
  29: DllCanUnloadNow
  30: DllCanUnloadNow
  31: DllCanUnloadNow
  32: DllCanUnloadNow
  33: Ordinal0
  34: DllCanUnloadNow
  35: CallWindowProcW
  36: DispatchMessageW
  37: tao::platform_impl::platform::event_loop::EventLoop<enum$<dioxus_desktop::UserWindowEvent> >::run_return<enum$<dioxus_desktop::UserWindowEvent>,dioxus_desktop::launch_with_props::closure$0>
             at C:\Users\ander\.cargo\registry\src\github.com-1ecc6299db9ec823\tao-0.5.2\src\platform_impl\windows\event_loop.rs:248
  38: tao::platform_impl::platform::event_loop::EventLoop<enum$<dioxus_desktop::UserWindowEvent> >::run<enum$<dioxus_desktop::UserWindowEvent>,dioxus_desktop::launch_with_props::closure$0>
             at C:\Users\ander\.cargo\registry\src\github.com-1ecc6299db9ec823\tao-0.5.2\src\platform_impl\windows\event_loop.rs:203
  39: tao::event_loop::EventLoop<enum$<dioxus_desktop::UserWindowEvent> >::run<enum$<dioxus_desktop::UserWindowEvent>,dioxus_desktop::launch_with_props::closure$0>
             at C:\Users\ander\.cargo\registry\src\github.com-1ecc6299db9ec823\tao-0.5.2\src\event_loop.rs:151
  40: dioxus_desktop::launch_with_props<tuple$<>,dioxus_desktop::launch::closure$0>
             at C:\Users\ander\.cargo\git\checkouts\dioxus-1e619ce595d3799d\4ea5c99\packages\desktop\src\lib.rs:163
  41: dioxus_desktop::launch
             at C:\Users\ander\.cargo\git\checkouts\dioxus-1e619ce595d3799d\4ea5c99\packages\desktop\src\lib.rs:98
  42: hello_dioxus::main
             at .\src\main.rs:4
  43: core::ops::function::FnOnce::call_once<void (*)(),tuple$<> >
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\library\core\src\ops\function.rs:227
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
webview2: panic in callback function. Aborting because it's UB to unwind across FFI boundaries.
error: process didn't exit successfully: `target\debug\hello-dioxus.exe` (exit code: 0xc0000409, STATUS_STACK_BUFFER_OVERRUN)

Looks like windows redirects the WebView when it loads. Try the jk/windows-desktop branch - I merged this fix in with the ICE fix but this fix hasn't been published to crates yet.

Sorry... I don't use windows so I didn't know about either of these!

from dioxus.

anderslanglands avatar anderslanglands commented on May 10, 2024

@jkelleyrtp yep that works now! Only weird thing is that the "Hello, world!" text doesn't render until I move or resize the window.

from dioxus.

jkelleyrtp avatar jkelleyrtp commented on May 10, 2024

@jkelleyrtp yep that works now! Only weird thing is that the "Hello, world!" text doesn't render until I move or resize the window.

Strange - but at least I know where to look. The event loop on windows probably sleeps or doesn't call the "events cleared" message. I'm getting the same behavior so at least I can debug it now.

from dioxus.

Patrick-Poitras avatar Patrick-Poitras commented on May 10, 2024

We've put the ICE into the database over on the language side.

from dioxus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.