stormalf / chibicc

A small C compiler from rui314
MIT License
6 stars 1 forks source link

ISS-174 at execution postgres loops in spinlock (infinite loop) #76

Open stormalf opened 3 weeks ago

stormalf commented 3 weeks ago

at execution postgres loops in spinlock (infinite loop) 0x0000000001c6212f in pg_usleep () at pgsleep.c:50

3 0x00000000014a03c3 in perform_spin_delay () at s_lock.c:150

4 0x00000000014a069b in s_lock () at s_lock.c:107

5 0x000000000143edd3 in ShmemAllocRaw () at ../../../../src/include/storage/s_lock.h:658

6 0x0000000001440d1e in ShmemAlloc () at shmem.c:157

7 0x00000000014770af in CreateLWLocks () at lwlock.c:459

8 0x0000000001412dac in CreateOrAttachShmemStructs () at ipci.c:268

9 0x000000000141364f in CreateSharedMemoryAndSemaphores () at ipci.c:234

10 0x00000000007f0645 in BootstrapModeMain () at bootstrap.c:312

11 0x0000000000ef6305 in main () at main.c:184

stormalf commented 3 weeks ago

it was caused by incorrect assembly code generated by chibicc when : asm volatile( " lock \n" " xchgb %0,%1 \n" : "+q"(_res), "+m"(lock) : / no inputs */ : "memory", "cc"); in this case, chibicc generates incorrect assembly code that causes the issue with postgres.

stormalf commented 3 weeks ago

The issue was not incorrect assembly generated but need to generate input for output even when no input in extended assembly. This will be fixed in 1.0.22.5 and 1.0.23.