Mingw64 generate_bare_map SegFault
Mingw64 segfaults on generate_bare_map due to a free that occurs when the function ends.
This function calls into wfc-rs, so it is likely some kind of double free situation. Perhaps the update to the wfc.h code in the latest commit, which fixes a leak (presumably by freeing some memory) free something that Rust then double-frees.
Look at the commit to wfc, where frees occur, and see if any of that memory is allocated in Rust. Consider something like asking Rust to ignore the memory if so.
Okay, I played around with this problem for a while and came up with a working setup.
- Use MSYS2 - the purple one. The Mingw64 (blue) reports an error for me, which I haven't figured out.
- Execute "rustup default stable-x86_64-pc-windows-msvc" as this is what I was using before. I fixed the issue with MSVC, so we can go back to that and not use the gnu compiler.
- Pull the lastest master. I had to remove some flags in wfc-rs which were passed to the msvc compiler but only meant for the gnu compiler.
The problem is clearly with pixel_bytes. std::mem::forget(pixel_bytes); before returning fixes the problems. Consider forgetting it in the wfc-rs crate, so it can be freed by the user of the vec?
The 'image' is also being leaked, because it is a raw pointer. Consider unwrapping the image.
Okay, I pushed a change that should fix this.
I updated the wfc-rs crate to make its memory management a bit safer. The one thing I'm not positive about is whether the pixel_bytes variable will still cause a crash. If it does, I will try another update to wfc-rs to move the 'forget' we added into the library, so we don't have to do it in the game's code. I will upload that change and we can try again.
This is still not really resolved. The game works, but we need a "std::mem::forget(pixel_bytes);" in procgen.rs for some reason.