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

Stack Overflow when using floem and libloading #107

Open
OueslatiGhaith opened this issue Sep 19, 2023 · 3 comments
Open

Stack Overflow when using floem and libloading #107

OueslatiGhaith opened this issue Sep 19, 2023 · 3 comments

Comments

@OueslatiGhaith
Copy link

Running this code results in a stack overflow. The code uses libloading to load a shared library libplugin.so

use floem::view::View;

fn main() {
    floem::launch(move || unsafe {
        let lib = libloading::Library::new("./target/debug/libplugin.so").unwrap();
        let func = lib
            .get::<unsafe fn() -> Box<dyn View>>(b"plugin_main")
            .unwrap();

        func()
    });
}

this the libplugin.so code

use floem::view::View;
use floem::views::{label, stack, text};

#[no_mangle]
pub fn plugin_main() -> Box<dyn View> {
    let view = stack((
        label(move || format!("Value: {}", 0)),
        stack((
            text("Increment"), 
            text("Decrement"),
        )),
    ));

    Box::new(view)
}

this is the cargo runoutput

thread 'main' has overflowed its stack
fatal runtime error: stack overflow
fish: Job 1, 'cargo run' terminated by signal SIGABRT (Abort)
@jrmoulton
Copy link
Collaborator

I've tried to do this too in and I can't get it to work (probably possible but I couldn't figure it out)

@OueslatiGhaith
Copy link
Author

this is a backtrace if anyone is interested
https://gist.github.com/OueslatiGhaith/1355c9f7f1714224fa76fcc2e839454c

the stack overflow happens because taffy::node::Taffy::mark_dirty_internal::mark_dirty_recursive is getting called in an infinite loop

@nicoburns
Copy link
Contributor

the stack overflow happens because taffy::node::Taffy::mark_dirty_internal::mark_dirty_recursive is getting called in an infinite loop

This is likely because there is a bug causing a cycle to be introduced into the node tree (making it not a tree anymore!). Taffy's mark_dirty method recurses up the tree until it finds a node with no parent. But if it never finds such a node because there is a cycle then it will enter an infinite loop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants