emilk / emilk/egui

Unhandled user callback exception on dynamic library interaction

Open
#5,152 3 comments 0 reactions 0 assignees View on GitHub
eframe native-windows
Dominant language
Rust
Stars
30.6k
Forks
2.1k
Avg merge
1d 9h
Merged PRs (30d)
72

Description

**Describe the bug**
When use dynamic library to render, clicking the exit button the application stop for seconds and exit with error.

**To Reproduce**
Steps to reproduce the behavior:
**main.rs**:
```rust
use eframe::egui::{self, Context};
use eframe::{App, Frame};
use libloading::{Library, Symbol};
use std::fs;

pub struct Program {
libs: Vec,
}

impl Default for Program {
fn default() -> Program {
let plugins = fs::read_dir("libs/").expect("no plugins folder!");
let mut libs = vec![];
for plugin in plugins {
unsafe {
let path = plugin.unwrap().path();
let lib = Library::new(path).expect("couldn't find dll");
libs.push(lib);
}
}
Self { libs }
}
}

impl App for Program {
fn update(&mut self, ctx: &Context, _frame: &mut Frame) {
for lib in &self.libs {
unsafe {
let func: Symbol = lib.get(b"render").unwrap();
func(ctx);
}
}
egui::SidePanel::right("main").show(ctx, |ui| {
ui.heading("My egui Application Main");
});
}
}

fn main() {
let options = eframe::NativeOptions {
viewport: egui::ViewportBuilder::default().with_inner_size([320.0, 240.0]),
..Default::default()
};
eframe::run_native(
"My egui App",
options,
Box::new(|_cc| Ok(Box::::default())),
)
.unwrap();
}
```
**lib.rs**:
```rust
use eframe::egui;
use eframe::egui::Context;

#[no_mangle]
pub fn render(ctx: &Context) {
egui::SidePanel::left("dll").show(ctx, |ui| {
ui.heading("My egui Application dll");
});
}
```
**Expected behavior**
Exit normally.

**Screenshots**
![image](https://github.com/user-attachments/assets/2d91916a-9119-4751-9543-f6861278c061)

**Desktop (please complete the following information):**
- OS: Windows11

**Additional context**
Error appears on both ``Glow`` and ``wgpu`` backend.
Both panic before dropping `painter`.
**Eframe version:** 0.28.1
Error ``0xc000041d`` exists when exception isn't handled in ``windows``' user callback.

Contributor guide

Open the contributing guide

Research direction

Start with the supplied main.rs and lib.rs reproduction on Windows 11 using eframe 0.28.1, then compare the exit behavior under both the Glow and wgpu backends. Done means the application exits normally without the reported 0xc000041d exception or a panic before the painter is dropped.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
desktop, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.