Git Product home page Git Product logo

Comments (5)

riverar avatar riverar commented on May 18, 2024

Hey @drewcrawford! The Window is getting disposed when OnLaunched returns, which is a bit awkward for WinUI.

Stash the main window instance in the App structure (that's why that field is there). There's a sample here as well: https://github.com/microsoft/windows-samples-rs/blob/master/windows_app_sdk/simple_window/src/main.rs#L59

from windows-app-rs.

drewcrawford avatar drewcrawford commented on May 18, 2024

I appreciate that workaround! However, this is a soundness issue. STATUS_ACCESS_VIOLATION is a memory violation, which isn't expected in safe rust. Assuming that's not a winui bug, it implies the rust projection ought to be marked unsafe.

For the rust side, see https://github.com/microsoft/windows-rs/blob/bf9da585055128b423473aae5e36df7bd5c91019/.github/safety.md#safety

For the winui side, it seems a bit awkward that an API like Window::new would be unsafe. Rust developers have a tendency to make wrappers for these cases, I'm a little uncertain whether that's in-scope here or more of a third-party crate.

from windows-app-rs.

kennykerr avatar kennykerr commented on May 18, 2024

In general, the xaml api will call C's abort function when used incorrectly in order to produce a Watson dump. This is considered safe on Windows because the process is immediately suspended and then terminated to prevent curruption.

from windows-app-rs.

drewcrawford avatar drewcrawford commented on May 18, 2024

Wouldn’t abort raise SIGABRT? Here we have access_violation, which I assume is some different signal (SIGSEGV presumably)

It’s a bit surprising that C abort could present like this crash, although maybe that is just how windows implements it?

from windows-app-rs.

kennykerr avatar kennykerr commented on May 18, 2024

I'm not a debugging expert but I think it depends on whether the abort was explicit or implicit. On Windows at least, you can abort explicitly via terminate/abort functions or implicitly by dereferencing a null pointer. The result is the same - suspension, dump, termination. This is a long-standing practice in COM code particularly and provides reliable crash dump information.

from windows-app-rs.

Related Issues (18)

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.