Page MenuHomePhabricator

QmitkDataStorageTreeModel is not 64 bit safe. DataTreeManager crashes on 64 Bit systems.
Closed, DuplicatePublic


QmitkDataStorageTreeModel::mimeData(..) and QmitkDataStorageTreeModel::dropMimeData(..) are not 64 bit safe!

To reproduce: start mitkWorkbench and raise the memory usage above 4GB. Then drag and drop nodes in DataManager (which have an address > 4GB) (e.g. to change order of visualization (loaded is one huge volume image and several surfaces; changing order of data nodes changes which surface is drawn on top))->application crashes.

Debugging showed, that it crashes in QmitkDataStorageTreeModel.cpp line 200:

if(listOfItemsToDrop[0] != dropItem && listOfItemsToDrop[0]->GetParent() == parentItem)

The reason for the crash was that address of listOfItemsToDrop[0] was not valid anymore and therefore calling GetParent() was not possible.

Root cause for the invalid address was the conversion into/from QMimeData in QmitkDataStorageTreeModel::mimeData(..) and QmitkDataStorageTreeModel::dropMimeData(..) because on a 64bit system only the lower 32 bits of the address are converted. Reason for that is the usage of "long" which 32 bit only (also on 64 bit systems) in the following lines of code of QmitkDataStorageTreeModel.cpp:

method QmitkDataStorageTreeModel::mimeData(..):
299: long treeItemAddress = reinterpret_cast<long>(treeItem);
300: long dataNodeAddress = reinterpret_cast<long>(treeItem->GetDataNode().GetPointer());

method QmitkDataStorageTreeModel::dropMimeData(..)
182: long val = (*slIter).toLong();

Apart from that in line 183 reinterpret_cast<TreeItem*> should be used rather than static_cast on a c-style (void*)-pointer.

This might be a general problem whenever addresses are converted and may happen elsewhere as well. I would recommend searching to the whole solution whether this happens somewhere else as well.

;) Best,