Skip to content

Debug builds fail on Windows with Rust versions newer than 1.85.1 #628

@abose

Description

@abose

Summary

Debug builds (npm run server and other debug commands) fail when using Rust versions newer than 1.85.1 on Windows. The application crashes with a null pointer dereference in the tauri_plugin_single_instance package during initialization. We've temporarily locked our Rust version to 1.85.1 as a workaround.

Environment

  • Platform: Windows (only)
  • Build Mode: Debug only (release builds work fine)
  • Rust Versions Affected: Versions newer than 1.85.1
  • Commands Affected: npm run server and any other commands that build in debug mode

Error Details

The application crashes with a null pointer dereference during initialization of the tauri_plugin_single_instance plugin. The error occurs in the Windows-specific implementation when creating the event target window.

Backtrace Highlights

panicking.rs:304 core::panicking::panic_null_pointer_dereference
windows.rs:109 tauri_plugin_single_instance::platform_impl::single_instance_window_proc<tauri_runtime_wry::Wry<enum2$<tauri::EventLoopMessage> > >
...
windows.rs:151 tauri_plugin_single_instance::platform_impl::create_event_target_window<tauri_runtime_wry::Wry<enum2$<tauri::EventLoopMessage> > >
windows.rs:67 tauri_plugin_single_instance::platform_impl::init::closure$0<tauri_runtime_wry::Wry<enum2$<tauri::EventLoopMessage> > >

Research & Analysis

  1. The issue is specific to Windows and only occurs in debug builds (with debug assertions enabled)
  2. The problem is in the Windows-specific implementation of tauri_plugin_single_instance
  3. It seems to be related to how the plugin initializes and creates Windows API-based event windows
  4. The null pointer dereference suggests a value that was previously valid in Rust 1.85.1 is now null in newer versions
  5. Release builds work normally, suggesting this is related to debug-specific memory layout or assertions

Current Workaround

We've temporarily locked the Rust version to 1.85.1 in both our local development environment and CI pipeline:

Local Environment:

rustup default 1.85.1

GitHub Actions:

- name: install specific Rust version
  uses: dtolnay/rust-toolchain@master
  with:
    toolchain: 1.85.1

Potential Solutions

When we want to upgrade Rust in the future, we should consider these options:

  1. Check for updates to tauri-plugin-single-instance that might fix compatibility with newer Rust versions

  2. Conditionally disable the plugin in debug mode on Windows:

    #[cfg(not(all(debug_assertions, target_os = "windows")))]
    {
      // Only initialize single-instance plugin in release mode or non-Windows platforms
      app = app.plugin(tauri_plugin_single_instance::init(|app, argv, cwd| {
        // Single-instance handling
      }));
    }
  3. Fork and fix the plugin - The issue is likely in the Windows-specific module of the plugin

  4. Contact the plugin maintainers - File an issue in the plugin repository with our findings

Next Steps

  • Create an issue in the tauri-plugin-single-instance repository
  • Investigate if we can conditionally disable the plugin for Windows debug builds
  • Revisit this issue when attempting to upgrade Rust in the future

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdependenciesPull requests that update a dependency filerustPull requests that update Rust codewindowsIssues affecting Windows OS

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions