Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
4.8.3
-
Qt4.8.3
-
bb5d287cc3eb68e1e46e5c3eb0a2c3991900354d
Description
QSharedMemoryPrivate::create(int size) on $QTDIR/src/corelib/kernel/qsharedmemory_win.cpp (Qt4.8.3)
handles wrong return value if sharedmem already exists:
hand = CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, size, (wchar_t*)nativeKey.utf16()); setErrorString(QLatin1String("QSharedMemory::create")); // hand is valid when it already exists unlike unix so explicitly check return !(error == QSharedMemory::AlreadyExists || !hand);
This code does not work right because QLatin1String("QSharedMemory::create") and creating a Qstring when passing
argument to setErrorString calls malloc() which resets GetLastError(), so setErrorString() does not set
error to the GetLastError() of CreateFileMapping() but of malloc. This used to work in 4.7.3 as there the
code did not make the QLatin1String inplace but at the top of the function. The caller
thinks the shared memory was created by him, even if it already exists and reinits the memory.
Proposal:
make a second parameter to setErrorString() as DWORD LastError and every call is made as
setErrorString(QLatin1String(__FUNCSIG__),GetLastError());
Attachments
Issue Links
- is duplicated by
-
QTBUG-27744 QSharedMemory inconsistent behaviour in Windows
- Closed