mirror of
https://github.com/riscv-software-src/riscv-isa-sim.git
synced 2025-10-14 02:07:30 +08:00

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
21 lines
322 B
C
21 lines
322 B
C
#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;
|
|
}
|