From a1116feb60fa463f928137b23b5260b02e55677e Mon Sep 17 00:00:00 2001 From: hvlad Date: Tue, 7 Jul 2020 16:06:18 +0300 Subject: [PATCH] Additional fix for bug CORE-6253 : Crash caused by the locked fb_lock file Retry attempts to initialize shared memory when truncation of shmem file was failed with ERROR_USER_MAPPED_FILE. The case is when last process that holds shared memory and its initialization event was killed (or crashed) and didn't released OS objects in correct order (event, file, memory mappings). I.e. new process successfully creates event, correctly consider itself as initializator, but failed to truncate file as it is still in use by old instance of memory mappings in killed\crashed process. This prevents bugcheck in LM and abort() as consequence. --- src/common/isc_sync.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/common/isc_sync.cpp b/src/common/isc_sync.cpp index 9400dbcdd9..d14ea162dc 100644 --- a/src/common/isc_sync.cpp +++ b/src/common/isc_sync.cpp @@ -2248,7 +2248,12 @@ SharedMemoryBase::SharedMemoryBase(const TEXT* filename, ULONG length, IpcObject CloseHandle(file_handle); if (err == ERROR_USER_MAPPED_FILE) + { + if (retry_count < 50) // 0.5 sec + goto retry; + Arg::Gds(isc_instance_conflict).raise(); + } else system_call_failed::raise("SetFilePointer", err); }