tomassedovic / tcod-rs

Rust bindings for libtcod 1.6.3 (the Doryen library/roguelike toolkit)
Do What The F*ck You Want To Public License
229 stars 45 forks source link

Segmentation fault on Image creation #307

Open svenknobloch opened 4 years ago

svenknobloch commented 4 years ago

Running on OSX 10.14 (Mojave)

Creation of image from console segfaults on this line when dereferencing the pixel pointer.

Minimalistic example that reproduces the error (happens on both Offscreen and Root):

let console = Offscreen::new(100, 100);
let image = Image::from_console(&console);
tomassedovic commented 4 years ago

Hey @svenknobloch, thanks for this!

Looks like this is an issue with the bundled libtcod source. This project uses by now a very old version and I suspect the best thing to do would be to update it.

There was an attempt at that here:

https://github.com/tomassedovic/tcod-rs/pull/290

But it stalled and unless someone's able to bring it to the finish line, it probably won't happen :-(. I have basically zero time/energy to work on tcod-rs these days.

svenknobloch commented 4 years ago

That's understandable. I might take a look at it, since I would like to use it.

Also if the bundled version is causing the issue, do you think dynamically linking it with a newer installed version might work, just as a sanity check? Or would the new version not be compatible, binding-wise?

tomassedovic commented 4 years ago

I think if both versions use the same function headers (same arguments in the same order and the same return function) it should work. If not, you've got yourself another segfault.

If you just want something that works, an alternative might be to try RLTK: http://bfnightly.bracketproductions.com/rustbook/

or doryen-rs: https://github.com/jice-nospam/doryen-rs

They're both roguelike libs in pure Rust, so depending on what exactly you want to do, they might be worth looking at.