[LLVMbugs] [Bug 23817] New: Local static variable initialization is not thread safe
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Thu Jun 11 05:49:27 PDT 2015
https://llvm.org/bugs/show_bug.cgi?id=23817
Bug ID: 23817
Summary: Local static variable initialization is not thread
safe
Product: compiler-rt
Version: 3.6
Hardware: PC
OS: Windows NT
Status: NEW
Severity: release blocker
Priority: P
Component: compiler-rt
Assignee: unassignedbugs at nondot.org
Reporter: ali.demiroz at sap.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
llvm-3.6.0rc4.src\lib\Support\Windows\Memory.inc at line 81, there is a local
static variable usage to ensure calling "getAllocationGranularity" function
only once.
But unlike GCC, MSVC does not use any barrier to provide synchronization for
local-scoped static variables.
So as a consequence, this code causes a division by zero at line 82 in
Memory.inc when second thread sees that cs:dword_143A26070 is set but
cs:off_143A26068 is initialized yet.
Generated assembly:
mov eax, cs:dword_143A26070
test al, 1
jnz short loc_14251B165
or eax, 1
lea rcx, [rsp+88h+var_38]
mov cs:dword_143A26070, eax
call cs:__imp_GetSystemInfo
mov eax, [rsp+88h+var_34]
mov ecx, [rsp+88h+var_10]
cmp eax, ecx
jbe short loc_14251B159
mov ecx, eax
loc_14251B159:
mov cs:off_143A26068, rcx
xor r8d, r8d
jmp short loc_14251B16C
loc_14251B165:
mov rcx, cs:off_143A26068
loc_14251B16C:
xor edx, edx
lea rax, [rbp-1]
add rax, rcx
div rcx
mov qword ptr [rsp+88h+var_58], rax
test rdi, rdi
jz short loc_14251B1C0
...
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150611/154b3a74/attachment.html>
More information about the llvm-bugs
mailing list