Browse Source
Since 92e4f02 moved logging logic into store_slow_path function it has
been logging stores even if actually_store parameter is false. Because
of that logging is broken for all atomic instructions. Function "amo" calls
store_slow_path with nullptr argument and actually_store equal to false
while callee uses reg_from_bytes independently from actually_store value
All of that causes dereferencing of nullptr. This commit logs memory
access only if it actually happened
pull/1995/head
4 changed files with 30 additions and 3 deletions
@ -0,0 +1,20 @@ |
|||||
|
#include <stdio.h> |
||||
|
#include <stdatomic.h> |
||||
|
|
||||
|
atomic_int acnt = 0; |
||||
|
atomic_int bcnt = 0; |
||||
|
|
||||
|
int foo() { |
||||
|
for(int n = 0; n < 1000; ++n) { |
||||
|
++acnt; |
||||
|
if(acnt % 10 == 0) |
||||
|
++bcnt; |
||||
|
} |
||||
|
return acnt; |
||||
|
} |
||||
|
|
||||
|
int main(void) { |
||||
|
int acnt = foo(); |
||||
|
printf("First atomic counter is %u, second is %u\n", acnt, bcnt); |
||||
|
return 0; |
||||
|
} |
||||
Loading…
Reference in new issue