RFR 8224676: Java crash if VSYSCALL is missing

Vladimir Kempik vkempik at azul.com
Fri May 24 10:09:18 UTC 2019


Hello

sched_getcpu may be not present in libc ( in case of musl).
if it’s so, then java tries to use VSYSCALL routine which causes sigsegv on some kernel configurations.

there’s a machanism in zgc to cache os::processor_id results and since libc’s sched_getcpu call seems to use getcpu syscall anyway.
other solutions would be to unify x86_64 and i386 routines in sched::getcpu_syscall.

which would look this:


int os::Linux::sched_getcpu_syscall(void) {
  unsigned int cpu = 0;
  int retval = -1;

  #ifndef SYS_getcpu
    #define SYS_getcpu 318
  #endif
  retval = syscall(SYS_getcpu, &cpu, NULL, NULL);

  return (retval == -1) ? retval : cpu;

}

24 мая 2019 г., в 12:58, Florian Weimer <fweimer at redhat.com<mailto:fweimer at redhat.com>> написал(а):

* Vladimir Kempik:

This patch remove VSYSCALL functionality and does perform simple asm
instruction to get cpu id.

I don't think this is future-proof because the kernel may store the CPU
number in another way and update the code in the vDSO accordingly.
Using the segment limit is an implementation detail.

Is there a reason why you can't call sched_getcpu?  Is it too slow?

Thanks,
Florian



More information about the hotspot-runtime-dev mailing list