tcod-rs icon indicating copy to clipboard operation
tcod-rs copied to clipboard

Segmentation fault on Image creation

Open svenknobloch opened this issue 5 years ago • 3 comments

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);

svenknobloch avatar Feb 21 '20 17:02 svenknobloch

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.

tomassedovic avatar Feb 21 '20 20:02 tomassedovic

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?

svenknobloch avatar Feb 23 '20 15:02 svenknobloch

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.

tomassedovic avatar Feb 24 '20 21:02 tomassedovic