https://bugs.kde.org/show_bug.cgi?id=383339

--- Comment #17 from Alvin Wong <alvinhoc...@gmail.com> ---
I think this is the problem:

#1  0x00000000004081b6 in gmic_qt_output_images (images=..., imageNames=...,
mode=mode@entry=GmicQt::InPlace) at src\host_krita.cpp:266
266             memcpy(m->data(), gimg._data, m->size());


Looking at the code:

257             QSharedMemory *m = new
QSharedMemory(QString("key_%1").arg(QUuid::createUuid().toString()));
258             sharedMemorySegments.append(m);
259
260             if (!m->create(gimg._width * gimg._height * gimg._spectrum *
sizeof(float))) {
261                 qWarning() << "Could not create shared memory" <<
m->error() << m->errorString();
262                 return;
263             }
264
265             m->lock();
266             memcpy(m->data(), gimg._data, m->size());
267             m->unlock();


The size requested for `m` is:

(gdb) p gimg._width * gimg._height * gimg._spectrum * sizeof(float)
$12 = 52862080 (0x3269C80)


But the actual size for `m` is:

(gdb) p m->size()
$13 = 52862976 (0x326A000)


So it looks like at least on Windows, QSharedMemory can have a size larger than
the requested size for alignment purpose.
It should use `gimg._width * gimg._height * gimg._spectrum * sizeof(float)`
directly instead.
This might be a defect in Qt's documentation.
Why it didn't crash on other images is entirely due to sheer luck (it could've
corrupted some other memory, who knows).

@Boud:
Please check all the usage of `QSharedMemory::size()` in both gmic-qt and
Krita.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to