mapeditor / tiled

Flexible level editor
https://www.mapeditor.org/
Other
11.03k stars 1.74k forks source link

Segmentation fault with libtiled #2814

Open josephgarnier opened 4 years ago

josephgarnier commented 4 years ago

TiledMap Editor work very nice, but I get an Segmentation fault when I work with libtiled library to read a tmx file for my personnal project. Until now I was working with version 1.0.3 and it worked fine, but when I upgraded to version 1.3.4 then 1.3.5, I got the error. The map can be loaded but seg fault happens when I quit the application, so when the QMainWindow destructor is called.

To fix it, without success, I try with a very simple map (with one layer, one tileset with one brush) and I just put this code in a QMainWindow :

QFileInfo absoluteFilePath{QLatin1String{"../assets/maps/"} % "test"};
absoluteFilePath.makeAbsolute();
QLatin1String mapExtension{"tmx"};
if (absoluteFilePath.suffix() != mapExtension)
{
    absoluteFilePath = QFileInfo{absoluteFilePath.filePath() % QLatin1String{"."} % mapExtension};
}
Q_ASSERT_X(absoluteFilePath.isAbsolute(), "", "The path is not absolute");

Tiled::MapReader reader;
m_oMap = reader.readMap(absoluteFilePath.filePath()); // declared as std::unique_ptr<Tiled::Map> in header

Error:

Signal name : SIGSEGV
Signal meaning : Segmentation fault

Call Stack:

1 ??
2 QVector::destruct qvector.h 351 0x7ffff7af933d 3 QVector::freeData qvector.h 542 0x7ffff7af7fdf 4 QVector::~QVector qvector.h 73 0x7ffff7af6e96 5 Tiled::CutTiles::~CutTiles imagecache.cpp 65 0x7ffff7af67d4 6 QHashNode<Tiled::TilesheetParameters, Tiled::CutTiles>::~QHashNode qhash.h 149 0x7ffff7af9df2 7 QHash<Tiled::TilesheetParameters, Tiled::CutTiles>::deleteNode2 qhash.h 547 0x7ffff7af9e26 8 QHashData::free_helper qhash.cpp 572 0x7ffff6166499 9 QHash<Tiled::TilesheetParameters, Tiled::CutTiles>::freeData qhash.h 587 0x7ffff7af9e4d 10 QHash<Tiled::TilesheetParameters, Tiled::CutTiles>::~QHash qhash.h 254 0x7ffff7afa242 11 __cxa_finalize 0x7ffff532e615 12 __do_global_dtors_aux 0x7ffff7ae4fd3 13 ?? 0x7fffffffe2c0

My config:

bjorn commented 3 years ago

@josephgarnier If this is still a problem you're running into, could you please attach the complete source code of the program you're using to reproduce this issue?

Tiled repository has numerous applications that are loading maps and I'm not aware of any of them crashing on exit. Having a complete example should help to quickly find out what's causing this.

josephgarnier commented 3 years ago

My code is inside a big project but ok I quite understand. I'll create a new project and prepare a use case for you 👍