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

load_texture() segfaults in multi-threaded environment #424

Closed
sloganking opened this issue Jun 18, 2022 · 1 comment
Closed

load_texture() segfaults in multi-threaded environment #424

sloganking opened this issue Jun 18, 2022 · 1 comment

Comments

@sloganking
Copy link
Contributor

sloganking commented Jun 18, 2022

Problem

cargo.toml dependencies:

[dependencies]
macroquad = "0.3"
futures = {version = "0.3.21", features = ["thread-pool", "executor"]}

main.rs:

use futures::task::SpawnExt;
use futures::executor::ThreadPool;
use macroquad::prelude::load_texture;

async fn test_load_texture(dir: &str){
    println!("test1");
    load_texture(&dir).await;
    println!("test2");
}

#[macroquad::main("test")]
async fn main() {
    let pool = ThreadPool::new().unwrap();

    let f = test_load_texture("./test.png");
    
    pool.spawn(f).unwrap();

    println!("Hello there!");
}

When ./text.png exists, running the above yields

Hello there!
test1
Segmentation fault (core dumped)

Note

@not-fl3
Copy link
Owner

not-fl3 commented Jun 18, 2022

macroquad assume that all the call are done from the single thread (we have only one thread on wasm anyway), multithreaded calls are not supported by design.

There should be some runtime checks on this, but this is not implemented yet.

@not-fl3 not-fl3 closed this as completed Jun 18, 2022
sloganking added a commit to sloganking/TileView that referenced this issue Jun 18, 2022
doesn't work because macroquad does not support multiple threads. See not-fl3/macroquad#424
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

2 participants