dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
14.94k stars 4.64k forks source link

Linux Arm64 corrupted argument stuct values passed to static method #12068

Closed aviviadi closed 4 years ago

aviviadi commented 5 years ago

The called method BuildPosixMemoryInfoResult: https://github.com/ravendb/ravendb/blob/v4.2/src/Sparrow/LowMemory/MemoryInformation.cs#L362-L365 get 7 arguments which are ALL structs.

Adding before the call to BuildPosixMemoryInfoResult :

Console.WriteLine($"(a) - {workingSet.GetHashCode()} " + workingSet.GetValue(SizeUnit.Bytes));
Console.WriteLine("WAITING...");
Console.ReadKey();

gdb -> bt, info registers, disassemble : gives some results (see below)

and as first line inside the static method:

Console.WriteLine($"(b) - {workingSet.GetHashCode()} " + workingSet.GetValue(SizeUnit.Bytes));
Console.WriteLine("WAITING...");
Console.ReadKey();

same gdb commands as above bring results which seems like a stack corruption (struct -> stack -> misalignment ?)

Important Note: The same code with the same scenario works fine on linux-x64, win-x86, win-x64 and on arm-32 All tests were done in release builds.

Console Output:

(a) - 1088001248 162840576
WAITING...
(b) - 1088001248 281470681743360
WAITING...

As can be seen: 162840576 != 281470681743360

aviviadi commented 5 years ago

And the gdb output (first before calling the function, and the second immediately after):

[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/aarch64-linux-gnu/libthread_db.so.1".
0x0000ffff9d157a48 in __libc_read (fd=<optimized out>, buf=0xffffe4c14d50, nbytes=1024) at ../sysdeps/unix/sysv/linux/read.c:27
27  ../sysdeps/unix/sysv/linux/read.c: No such file or directory.
(gdb) c
Continuing.
[Thread 0xffff95f821d0 (LWP 2318) exited]
^C
Thread 1 "Raven.Server" received signal SIGINT, Interrupt.
0x0000ffff9d15422c in futex_wait_cancelable (private=<optimized out>, expected=0, futex_word=0x357fd4f4) at ../sysdeps/unix/sysv/linux/futex-internal.h:88
88  ../sysdeps/unix/sysv/linux/futex-internal.h: No such file or directory.
(gdb) bt
#0  0x0000ffff9d15422c in futex_wait_cancelable (private=<optimized out>, expected=0, futex_word=0x357fd4f4) at ../sysdeps/unix/sysv/linux/futex-internal.h:88
dotnet/coreclr#1  __pthread_cond_wait_common (abstime=0x0, mutex=0x357fd498, cond=0x357fd4c8) at pthread_cond_wait.c:502
dotnet/coreclr#2  __pthread_cond_wait (cond=0x357fd4c8, mutex=0x357fd498) at pthread_cond_wait.c:655
dotnet/coreclr#3  0x0000ffff9c88adfc in CorUnix::CPalSynchronizationManager::ThreadNativeWait(CorUnix::_ThreadNativeWaitData*, unsigned int, CorUnix::ThreadWakeupReason*, unsigned int*) () from /mnt/nvme1n1/RavenDB-arm64/libcoreclr.so
dotnet/coreclr#4  0x0000ffff9c88aa3c in CorUnix::CPalSynchronizationManager::BlockThread(CorUnix::CPalThread*, unsigned int, bool, bool, CorUnix::ThreadWakeupReason*, unsigned int*) () from /mnt/nvme1n1/RavenDB-arm64/libcoreclr.so
dotnet/coreclr#5  0x0000ffff9c88ef10 in CorUnix::InternalWaitForMultipleObjectsEx(CorUnix::CPalThread*, unsigned int, void* const*, int, unsigned int, int, int) () from /mnt/nvme1n1/RavenDB-arm64/libcoreclr.so
dotnet/coreclr#6  0x0000ffff9c5312c8 in Thread::DoAppropriateWaitWorker(int, void**, int, unsigned int, WaitMode) () from /mnt/nvme1n1/RavenDB-arm64/libcoreclr.so
dotnet/coreclr#7  0x0000ffff9c52c008 in Thread::DoAppropriateWait(int, void**, int, unsigned int, WaitMode, PendingSync*) () from /mnt/nvme1n1/RavenDB-arm64/libcoreclr.so
dotnet/coreclr#8  0x0000ffff9c52b4d8 in AwareLock::EnterEpilogHelper(Thread*, int) () from /mnt/nvme1n1/RavenDB-arm64/libcoreclr.so
dotnet/coreclr#9  0x0000ffff9c52b048 in AwareLock::Enter() () from /mnt/nvme1n1/RavenDB-arm64/libcoreclr.so
dotnet/coreclr#10 0x0000ffff9c5a92d0 in JIT_MonEnter_Helper(Object*, unsigned char*, void*) () from /mnt/nvme1n1/RavenDB-arm64/libcoreclr.so
dotnet/coreclr#11 0x0000ffff9c5a95ec in JIT_MonReliableEnter_Portable () from /mnt/nvme1n1/RavenDB-arm64/libcoreclr.so
dotnet/coreclr#12 0x0000ffff23874d18 in ?? ()
dotnet/coreclr#13 0x0000ffff243581fc in ?? ()
dotnet/coreclr#14 0x0000ffff26622580 in ?? ()
dotnet/coreclr#15 0x0000fffbdc1f74f8 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
(gdb) info registers 
x0             0x357fd4f4   897570036
x1             0x80 128
x2             0x0  0
x3             0x0  0
x4             0xffffffbb   4294967227
x5             0xffff9d1a7ee0   281473317502688
x6             0x0  0
x7             0x0  0
x8             0x62 98
x9             0x4  4
x10            0x0  0
x11            0x0  0
x12            0x3  3
x13            0x8f734f3b73afee00   -8110051387201556992
x14            0x70d191 7393681
x15            0xf  15
x16            0xffff9cb84770   281473311065968
x17            0xffff9d153ff8   281473317158904
x18            0xffff9cecea70   281473314515568
x19            0x357fd4dc   897570012
x20            0xffff9d16d000   281473317261312
x21            0x357fd498   897569944
x22            0x13 19
x23            0xffff9d153f40   281473317158720
x24            0x1  1
x25            0x9  9
x26            0x357fd4f4   897570036
x27            0x0  0
x28            0x357fd4c8   897569992
x29            0xffffe4c14b10   281474519616272
x30            0xffff9d154210   281473317159440
sp             0xffffe4c14b10   0xffffe4c14b10
pc             0xffff9d15422c   0xffff9d15422c <__pthread_cond_wait+564>
cpsr           0x80000000   [ EL=0 N ]
fpsr           0x11 17
fpcr           0x0  0
(gdb) disassemble 
Dump of assembler code for function __pthread_cond_wait:
   0x0000ffff9d153ff8 <+0>: stp x29, x30, [sp, #-208]!
   0x0000ffff9d153ffc <+4>: mov x29, sp
   0x0000ffff9d154000 <+8>: stp x19, x20, [sp, dotnet/coreclr#16]
   0x0000ffff9d154004 <+12>:    adrp    x20, 0xffff9d16d000
   0x0000ffff9d154008 <+16>:    stp x27, x28, [sp, dotnet/coreclr#80]
   0x0000ffff9d15400c <+20>:    mov x28, x0
   0x0000ffff9d154010 <+24>:    ldr x0, [x20, dotnet/coreclr#4008]
   0x0000ffff9d154014 <+28>:    stp x21, x22, [sp, dotnet/coreclr#32]
   0x0000ffff9d154018 <+32>:    mov x21, x1
   0x0000ffff9d15401c <+36>:    stp x24, x25, [sp, dotnet/coreclr#56]
   0x0000ffff9d154020 <+40>:    ldr x1, [x0]
   0x0000ffff9d154024 <+44>:    str x1, [x29, dotnet/runtime#3954]
   0x0000ffff9d154028 <+48>:    mov x1, #0x0                    // #0
   0x0000ffff9d15402c <+52>:    nop
   0x0000ffff9d154030 <+56>:    ldaxr   x22, [x28]
   0x0000ffff9d154034 <+60>:    add x0, x22, #0x2
   0x0000ffff9d154038 <+64>:    stxr    w1, x0, [x28]
   0x0000ffff9d15403c <+68>:    cbnz    w1, 0xffff9d154030 <__pthread_cond_wait+56>
   0x0000ffff9d154040 <+72>:    and w24, w22, #0x1
   0x0000ffff9d154044 <+76>:    lsr x25, x22, dotnet/coreclr#1
   0x0000ffff9d154048 <+80>:    add x0, x28, #0x24
   0x0000ffff9d15404c <+84>:    ldxr    w6, [x0]
   0x0000ffff9d154050 <+88>:    add w1, w6, #0x8
   0x0000ffff9d154054 <+92>:    stxr    w2, w1, [x0]
   0x0000ffff9d154058 <+96>:    cbnz    w2, 0xffff9d15404c <__pthread_cond_wait+84>
   0x0000ffff9d15405c <+100>:   ands    w27, w6, #0x1
   0x0000ffff9d154060 <+104>:   mov w0, #0x80                   // dotnet/runtime#3917
   0x0000ffff9d154064 <+108>:   mov w1, #0x0                    // #0
   0x0000ffff9d154068 <+112>:   csel    w27, w27, w0, eq  // eq = none
   0x0000ffff9d15406c <+116>:   mov x0, x21
   0x0000ffff9d154070 <+120>:   bl  0xffff9d151d68 <__pthread_mutex_unlock_usercnt>
   0x0000ffff9d154074 <+124>:   mov w19, w0
   0x0000ffff9d154078 <+128>:   cbnz    w0, 0xffff9d154268 <__pthread_cond_wait+624>
   0x0000ffff9d15407c <+132>:   mov w0, w24
   0x0000ffff9d154080 <+136>:   add x5, x28, #0x28
   0x0000ffff9d154084 <+140>:   str x23, [x29, dotnet/coreclr#48]
   0x0000ffff9d154088 <+144>:   lsl x19, x0, dotnet/coreclr#2
   0x0000ffff9d15408c <+148>:   str x26, [x29, dotnet/runtime#3885]
   0x0000ffff9d154090 <+152>:   str x0, [x29, dotnet/runtime#3913]
   0x0000ffff9d154094 <+156>:   add x26, x5, x19
   0x0000ffff9d154098 <+160>:   ldar    w0, [x26]
   0x0000ffff9d15409c <+164>:   add x19, x28, x19
   0x0000ffff9d1540a0 <+168>:   adrp    x23, 0xffff9d153000 <__GI___pthread_rwlock_wrlock+312>
   0x0000ffff9d1540a4 <+172>:   add x19, x19, #0x10
   0x0000ffff9d1540a8 <+176>:   add x23, x23, #0xf40
   0x0000ffff9d1540ac <+180>:   add x1, x29, #0xa8
   0x0000ffff9d1540b0 <+184>:   str x1, [x29, dotnet/coreclr#112]
   0x0000ffff9d1540b4 <+188>:   tbnz    w0, #0, 0xffff9d1540e8 <__pthread_cond_wait+240>
   0x0000ffff9d1540b8 <+192>:   cbz w0, 0xffff9d1541c4 <__pthread_cond_wait+460>
   0x0000ffff9d1540bc <+196>:   sub w1, w0, #0x2
   0x0000ffff9d1540c0 <+200>:   ldaxr   w2, [x26]
   0x0000ffff9d1540c4 <+204>:   cmp w2, w0
   0x0000ffff9d1540c8 <+208>:   b.ne    0xffff9d1540d4 <__pthread_cond_wait+220>  // b.any
   0x0000ffff9d1540cc <+212>:   stxr    w3, w1, [x26]
   0x0000ffff9d1540d0 <+216>:   cmp w3, #0x0
   0x0000ffff9d1540d4 <+220>:   b.ne    0xffff9d1542d0 <__pthread_cond_wait+728>  // b.any
   0x0000ffff9d1540d8 <+224>:   add x1, x28, #0x8
   0x0000ffff9d1540dc <+228>:   ldr x0, [x1]
   0x0000ffff9d1540e0 <+232>:   cmp x25, x0, lsr dotnet/coreclr#1
   0x0000ffff9d1540e4 <+236>:   b.cc    0xffff9d154138 <__pthread_cond_wait+320>  // b.lo, b.ul, b.last
   0x0000ffff9d1540e8 <+240>:   mov w1, w27
   0x0000ffff9d1540ec <+244>:   mov x0, x28
   0x0000ffff9d1540f0 <+248>:   bl  0xffff9d153c70 <__condvar_confirm_wakeup>
   0x0000ffff9d1540f4 <+252>:   mov x0, x21
   0x0000ffff9d1540f8 <+256>:   bl  0xffff9d1524c8 <__pthread_mutex_cond_lock>
   0x0000ffff9d1540fc <+260>:   ldr x23, [x29, dotnet/coreclr#48]
   0x0000ffff9d154100 <+264>:   ldr x26, [x29, dotnet/runtime#3885]
   0x0000ffff9d154104 <+268>:   mov w19, w0
   0x0000ffff9d154108 <+272>:   ldr x20, [x20, dotnet/coreclr#4008]
   0x0000ffff9d15410c <+276>:   mov w0, w19
   0x0000ffff9d154110 <+280>:   ldr x2, [x29, dotnet/runtime#3954]
   0x0000ffff9d154114 <+284>:   ldr x1, [x20]
   0x0000ffff9d154118 <+288>:   eor x1, x2, x1
   0x0000ffff9d15411c <+292>:   cbnz    x1, 0xffff9d1542d8 <__pthread_cond_wait+736>
---Type <return> to continue, or q <return> to quit---
   0x0000ffff9d154120 <+296>:   ldp x19, x20, [sp, dotnet/coreclr#16]
   0x0000ffff9d154124 <+300>:   ldp x21, x22, [sp, dotnet/coreclr#32]
   0x0000ffff9d154128 <+304>:   ldp x24, x25, [sp, dotnet/coreclr#56]
   0x0000ffff9d15412c <+308>:   ldp x27, x28, [sp, dotnet/coreclr#80]
   0x0000ffff9d154130 <+312>:   ldp x29, x30, [sp], dotnet/runtime#3959
   0x0000ffff9d154134 <+316>:   ret
   0x0000ffff9d154138 <+320>:   mvn x2, x0
   0x0000ffff9d15413c <+324>:   ldr x3, [x29, dotnet/runtime#3913]
   0x0000ffff9d154140 <+328>:   and x2, x2, #0x1
   0x0000ffff9d154144 <+332>:   cmp x3, x2
   0x0000ffff9d154148 <+336>:   b.ne    0xffff9d1540e8 <__pthread_cond_wait+240>  // b.any
   0x0000ffff9d15414c <+340>:   ldr w2, [x26]
   0x0000ffff9d154150 <+344>:   ldr x3, [x1]
   0x0000ffff9d154154 <+348>:   cmp x0, x3
   0x0000ffff9d154158 <+352>:   b.ne    0xffff9d1540e8 <__pthread_cond_wait+240>  // b.any
   0x0000ffff9d15415c <+356>:   tbnz    w2, #0, 0xffff9d154180 <__pthread_cond_wait+392>
   0x0000ffff9d154160 <+360>:   add w7, w2, #0x2
   0x0000ffff9d154164 <+364>:   ldxr    w3, [x26]
   0x0000ffff9d154168 <+368>:   cmp w3, w2
   0x0000ffff9d15416c <+372>:   b.ne    0xffff9d154178 <__pthread_cond_wait+384>  // b.any
   0x0000ffff9d154170 <+376>:   stxr    w4, w7, [x26]
   0x0000ffff9d154174 <+380>:   cmp w4, #0x0
   0x0000ffff9d154178 <+384>:   mov w2, w3
   0x0000ffff9d15417c <+388>:   b.ne    0xffff9d154150 <__pthread_cond_wait+344>  // b.any
   0x0000ffff9d154180 <+392>:   mov w1, #0x81                   // dotnet/coreclr#129
   0x0000ffff9d154184 <+396>:   eor w1, w27, w1
   0x0000ffff9d154188 <+400>:   mov x0, x26
   0x0000ffff9d15418c <+404>:   mov x2, #0x1                    // dotnet/coreclr#1
   0x0000ffff9d154190 <+408>:   sxtw    x1, w1
   0x0000ffff9d154194 <+412>:   mov x3, #0x0                    // #0
   0x0000ffff9d154198 <+416>:   mov x8, #0x62                   // dotnet/runtime#3902
   0x0000ffff9d15419c <+420>:   svc #0x0
   0x0000ffff9d1541a0 <+424>:   cmn x0, #0x1, lsl dotnet/coreclr#12
   0x0000ffff9d1541a4 <+428>:   b.ls    0xffff9d1540e8 <__pthread_cond_wait+240>  // b.plast
   0x0000ffff9d1541a8 <+432>:   cmn w0, #0x16
   0x0000ffff9d1541ac <+436>:   b.eq    0xffff9d1540e8 <__pthread_cond_wait+240>  // b.none
   0x0000ffff9d1541b0 <+440>:   cmn w0, #0xe
   0x0000ffff9d1541b4 <+444>:   b.eq    0xffff9d1540e8 <__pthread_cond_wait+240>  // b.none
   0x0000ffff9d1541b8 <+448>:   adrp    x0, 0xffff9d15a000 <__pthread_tpp_change_priority+736>
   0x0000ffff9d1541bc <+452>:   add x0, x0, #0xa70
   0x0000ffff9d1541c0 <+456>:   bl  0xffff9d14c240 <__libc_fatal@plt>
   0x0000ffff9d1541c4 <+460>:   ldaxr   w0, [x19]
   0x0000ffff9d1541c8 <+464>:   add w0, w0, #0x2
   0x0000ffff9d1541cc <+468>:   stxr    w1, w0, [x19]
   0x0000ffff9d1541d0 <+472>:   cbnz    w1, 0xffff9d1541c4 <__pthread_cond_wait+460>
   0x0000ffff9d1541d4 <+476>:   ldar    w0, [x26]
   0x0000ffff9d1541d8 <+480>:   tbnz    w0, #0, 0xffff9d1542bc <__pthread_cond_wait+708>
   0x0000ffff9d1541dc <+484>:   add x0, x28, #0x8
   0x0000ffff9d1541e0 <+488>:   ldr x0, [x0]
   0x0000ffff9d1541e4 <+492>:   cmp x25, x0, lsr dotnet/coreclr#1
   0x0000ffff9d1541e8 <+496>:   b.cc    0xffff9d1542bc <__pthread_cond_wait+708>  // b.lo, b.ul, b.last
   0x0000ffff9d1541ec <+500>:   ldr x2, [x29, dotnet/coreclr#112]
   0x0000ffff9d1541f0 <+504>:   add x0, x29, #0x88
   0x0000ffff9d1541f4 <+508>:   mov x1, x23
   0x0000ffff9d1541f8 <+512>:   str x0, [x29, dotnet/coreclr#104]
   0x0000ffff9d1541fc <+516>:   stp x22, x28, [x29, dotnet/runtime#3936]
   0x0000ffff9d154200 <+520>:   str x21, [x29, dotnet/coreclr#184]
   0x0000ffff9d154204 <+524>:   str w27, [x29, dotnet/runtime#3946]
   0x0000ffff9d154208 <+528>:   bl  0xffff9d157038 <_pthread_cleanup_push>
   0x0000ffff9d15420c <+532>:   bl  0xffff9d157430 <__pthread_enable_asynccancel>
   0x0000ffff9d154210 <+536>:   mov w7, w0
   0x0000ffff9d154214 <+540>:   eor w1, w27, #0x80
   0x0000ffff9d154218 <+544>:   mov x0, x26
   0x0000ffff9d15421c <+548>:   mov x2, #0x0                    // #0
   0x0000ffff9d154220 <+552>:   mov x3, #0x0                    // #0
   0x0000ffff9d154224 <+556>:   sxtw    x1, w1
   0x0000ffff9d154228 <+560>:   mov x8, #0x62                   // dotnet/runtime#3902
=> 0x0000ffff9d15422c <+564>:   svc #0x0
   0x0000ffff9d154230 <+568>:   mov x1, x0
   0x0000ffff9d154234 <+572>:   cmn x0, #0x1, lsl dotnet/coreclr#12
   0x0000ffff9d154238 <+576>:   b.hi    0xffff9d15428c <__pthread_cond_wait+660>  // b.pmore
   0x0000ffff9d15423c <+580>:   mov w0, w7
   0x0000ffff9d154240 <+584>:   bl  0xffff9d1574c0 <__pthread_disable_asynccancel>
   0x0000ffff9d154244 <+588>:   ldr x0, [x29, dotnet/coreclr#104]
   0x0000ffff9d154248 <+592>:   mov w1, #0x0                    // #0
---Type <return> to continue, or q <return> to quit---
   0x0000ffff9d15424c <+596>:   bl  0xffff9d157058 <_pthread_cleanup_pop>
   0x0000ffff9d154250 <+600>:   mov x0, x28
   0x0000ffff9d154254 <+604>:   mov w2, w27
   0x0000ffff9d154258 <+608>:   mov w1, w24
   0x0000ffff9d15425c <+612>:   bl  0xffff9d153d50 <__condvar_dec_grefs>
   0x0000ffff9d154260 <+616>:   ldar    w0, [x26]
   0x0000ffff9d154264 <+620>:   b   0xffff9d1540b4 <__pthread_cond_wait+188>
   0x0000ffff9d154268 <+624>:   mov w3, w27
   0x0000ffff9d15426c <+628>:   mov w2, w24
   0x0000ffff9d154270 <+632>:   mov x1, x25
   0x0000ffff9d154274 <+636>:   mov x0, x28
   0x0000ffff9d154278 <+640>:   bl  0xffff9d153dd0 <__condvar_cancel_waiting>
   0x0000ffff9d15427c <+644>:   mov w1, w27
   0x0000ffff9d154280 <+648>:   mov x0, x28
   0x0000ffff9d154284 <+652>:   bl  0xffff9d153c70 <__condvar_confirm_wakeup>
   0x0000ffff9d154288 <+656>:   b   0xffff9d154108 <__pthread_cond_wait+272>
   0x0000ffff9d15428c <+660>:   str x1, [x29, dotnet/coreclr#96]
   0x0000ffff9d154290 <+664>:   mov w0, w7
   0x0000ffff9d154294 <+668>:   bl  0xffff9d1574c0 <__pthread_disable_asynccancel>
   0x0000ffff9d154298 <+672>:   ldr x1, [x29, dotnet/coreclr#96]
   0x0000ffff9d15429c <+676>:   cmn w1, #0xb
   0x0000ffff9d1542a0 <+680>:   b.eq    0xffff9d1542ac <__pthread_cond_wait+692>  // b.none
   0x0000ffff9d1542a4 <+684>:   cmn w1, #0x4
   0x0000ffff9d1542a8 <+688>:   b.ne    0xffff9d1541b8 <__pthread_cond_wait+448>  // b.any
   0x0000ffff9d1542ac <+692>:   ldr x0, [x29, dotnet/coreclr#104]
   0x0000ffff9d1542b0 <+696>:   mov w1, #0x0                    // #0
   0x0000ffff9d1542b4 <+700>:   bl  0xffff9d157058 <_pthread_cleanup_pop>
   0x0000ffff9d1542b8 <+704>:   b   0xffff9d154250 <__pthread_cond_wait+600>
   0x0000ffff9d1542bc <+708>:   mov w2, w27
   0x0000ffff9d1542c0 <+712>:   mov w1, w24
   0x0000ffff9d1542c4 <+716>:   mov x0, x28
   0x0000ffff9d1542c8 <+720>:   bl  0xffff9d153d50 <__condvar_dec_grefs>
   0x0000ffff9d1542cc <+724>:   b   0xffff9d1540e8 <__pthread_cond_wait+240>
   0x0000ffff9d1542d0 <+728>:   mov w0, w2
   0x0000ffff9d1542d4 <+732>:   b   0xffff9d1540b4 <__pthread_cond_wait+188>
   0x0000ffff9d1542d8 <+736>:   str x23, [x29, dotnet/coreclr#48]
   0x0000ffff9d1542dc <+740>:   str x26, [x29, dotnet/runtime#3885]
   0x0000ffff9d1542e0 <+744>:   bl  0xffff9d14c3c0 <__stack_chk_fail@plt>
End of assembler dump.

AFTER POSSIBLE CORRUPTION:

(gdb) continue
Continuing.
[New Thread 0xffff967c41d0 (LWP 2350)]
[Thread 0xffff967c41d0 (LWP 2316) exited]
^C
Thread 1 "Raven.Server" received signal SIGINT, Interrupt.
0x0000ffff9d157a48 in __libc_read (fd=<optimized out>, buf=0xffffe4c14d50, nbytes=1024) at ../sysdeps/unix/sysv/linux/read.c:27
27  ../sysdeps/unix/sysv/linux/read.c: No such file or directory.
(gdb) bt
#0  0x0000ffff9d157a48 in __libc_read (fd=<optimized out>, buf=0xffffe4c14d50, nbytes=1024) at ../sysdeps/unix/sysv/linux/read.c:27
dotnet/coreclr#1  0x0000ffff970f5fb0 in SystemNative_ReadStdin () from /mnt/nvme1n1/RavenDB-arm64/System.Native.so
dotnet/coreclr#2  0x0000ffff26623f44 in ?? ()
dotnet/coreclr#3  0x0000000000499103 in ?? ()
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) info registers 
x0             0x0  0
x1             0xffffe4c14d50   281474519616848
x2             0x400    1024
x3             0x0  0
x4             0xffffffbb   4294967227
x5             0xffff9d1a7ee0   281473317502688
x6             0x0  0
x7             0x0  0
x8             0x3f 63
x9             0xffff970f5f84   281473216110468
x10            0xffff26623f44   281471325716292
x11            0xffff24330958   281471289067864
x12            0xffff24887fd0   281471294668752
x13            0xffffe4c14fd9   281474519617497
x14            0x12 18
x15            0x0  0
x16            0xffff9710d238   281473216205368
x17            0xffff9d1579e0   281473317173728
x18            0xffff9cecea70   281473314515568
x19            0x0  0
x20            0x400    1024
x21            0xffffe4c14d50   281474519616848
x22            0x1  1
x23            0x0  0
x24            0xfffbdc8216e8   281457201387240
x25            0x8  8
x26            0xffffe4c15800   281474519619584
x27            0xffffe4c15620   281474519619104
x28            0x1  1
x29            0xffffe4c14c30   281474519616560
x30            0xffff9d157a34   281473317173812
sp             0xffffe4c14c30   0xffffe4c14c30
pc             0xffff9d157a48   0xffff9d157a48 <__libc_read+104>
cpsr           0x80000000   [ EL=0 N ]
fpsr           0x11 17
fpcr           0x0  0
(gdb) disassemble 
Dump of assembler code for function __libc_read:
   0x0000ffff9d1579e0 <+0>: stp x29, x30, [sp, #-48]!
   0x0000ffff9d1579e4 <+4>: adrp    x3, 0xffff9d172000 <__pthread_keys+15688>
   0x0000ffff9d1579e8 <+8>: mov x29, sp
   0x0000ffff9d1579ec <+12>:    str x19, [sp, dotnet/coreclr#16]
   0x0000ffff9d1579f0 <+16>:    sxtw    x19, w0
   0x0000ffff9d1579f4 <+20>:    ldr w0, [x3, dotnet/runtime#4193]
   0x0000ffff9d1579f8 <+24>:    cbnz    w0, 0xffff9d157a24 <__libc_read+68>
   0x0000ffff9d1579fc <+28>:    mov x0, x19
   0x0000ffff9d157a00 <+32>:    mov x8, #0x3f                   // dotnet/coreclr#63
   0x0000ffff9d157a04 <+36>:    svc #0x0
   0x0000ffff9d157a08 <+40>:    mov x19, x0
   0x0000ffff9d157a0c <+44>:    cmn x0, #0x1, lsl dotnet/coreclr#12
   0x0000ffff9d157a10 <+48>:    b.hi    0xffff9d157a74 <__libc_read+148>  // b.pmore
   0x0000ffff9d157a14 <+52>:    mov x0, x19
   0x0000ffff9d157a18 <+56>:    ldr x19, [sp, dotnet/coreclr#16]
   0x0000ffff9d157a1c <+60>:    ldp x29, x30, [sp], dotnet/coreclr#48
   0x0000ffff9d157a20 <+64>:    ret
   0x0000ffff9d157a24 <+68>:    stp x20, x21, [x29, dotnet/coreclr#24]
   0x0000ffff9d157a28 <+72>:    mov x21, x1
   0x0000ffff9d157a2c <+76>:    mov x20, x2
   0x0000ffff9d157a30 <+80>:    bl  0xffff9d157430 <__pthread_enable_asynccancel>
   0x0000ffff9d157a34 <+84>:    mov x1, x21
   0x0000ffff9d157a38 <+88>:    mov w3, w0
   0x0000ffff9d157a3c <+92>:    mov x2, x20
   0x0000ffff9d157a40 <+96>:    mov x0, x19
   0x0000ffff9d157a44 <+100>:   mov x8, #0x3f                   // dotnet/coreclr#63
=> 0x0000ffff9d157a48 <+104>:   svc #0x0
   0x0000ffff9d157a4c <+108>:   mov x19, x0
   0x0000ffff9d157a50 <+112>:   cmn x0, #0x1, lsl dotnet/coreclr#12
   0x0000ffff9d157a54 <+116>:   b.hi    0xffff9d157a90 <__libc_read+176>  // b.pmore
   0x0000ffff9d157a58 <+120>:   mov w0, w3
   0x0000ffff9d157a5c <+124>:   bl  0xffff9d1574c0 <__pthread_disable_asynccancel>
   0x0000ffff9d157a60 <+128>:   mov x0, x19
   0x0000ffff9d157a64 <+132>:   ldr x19, [sp, dotnet/coreclr#16]
   0x0000ffff9d157a68 <+136>:   ldp x20, x21, [x29, dotnet/coreclr#24]
   0x0000ffff9d157a6c <+140>:   ldp x29, x30, [sp], dotnet/coreclr#48
   0x0000ffff9d157a70 <+144>:   ret
   0x0000ffff9d157a74 <+148>:   adrp    x0, 0xffff9d16d000
   0x0000ffff9d157a78 <+152>:   ldr x0, [x0, dotnet/runtime#5453]
   0x0000ffff9d157a7c <+156>:   mrs x1, tpidr_el0
   0x0000ffff9d157a80 <+160>:   neg w2, w19
   0x0000ffff9d157a84 <+164>:   mov x19, #0xffffffffffffffff        // #-1
   0x0000ffff9d157a88 <+168>:   str w2, [x1, x0]
   0x0000ffff9d157a8c <+172>:   b   0xffff9d157a14 <__libc_read+52>
   0x0000ffff9d157a90 <+176>:   adrp    x0, 0xffff9d16d000
   0x0000ffff9d157a94 <+180>:   ldr x0, [x0, dotnet/runtime#5453]
   0x0000ffff9d157a98 <+184>:   mrs x1, tpidr_el0
   0x0000ffff9d157a9c <+188>:   neg w2, w19
   0x0000ffff9d157aa0 <+192>:   mov x19, #0xffffffffffffffff        // #-1
   0x0000ffff9d157aa4 <+196>:   str w2, [x1, x0]
   0x0000ffff9d157aa8 <+200>:   b   0xffff9d157a58 <__libc_read+120>
End of assembler dump.
(gdb) 
RussKeldorph commented 5 years ago

@dotnet/jit-contrib @jashook

RussKeldorph commented 5 years ago

@dotnet/arm64-contrib

AndyAyersMS commented 5 years ago

cc @richlander

I believe arm64 on Linux in .Net Core 2.2 is just a preview, and full support requires 3.0. See for instance dotnet/announcements#82.

If you can reproduce this on 3.0, please let us know.

aviviadi commented 5 years ago

Checked on 3.0.0-preview-27324-5 : Works fine there! Thanks you @AndyAyersMS