TLAB initialization (in ThreadLocalAllocBuffer::initialize()) samples how much of capacity has actually been filled for statistics/resizing purposes:
size_t capacity = Universe::heap()->tlab_capacity(thread()) / HeapWordSize;
// Keep alloc_frac as float and not double to avoid the double to float conversion
float alloc_frac = desired_size() * target_refills() / (float) capacity;
That capacity can be zero (if e.g. there is no space left for allocation).
Adding an assert checking that capacity is > 0 here will crash the VM during shutdown (experienced only on OSX for whatever reason):
Stack: [0x000000016d454000,0x000000016d657000], sp=0x000000016d656d40, free space=2059k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [libjvm.dylib+0x1374050] VMError::report_and_die(int, char const*, char const*, char*, Thread*, unsigned char*, void*, void*, char const*, int, unsigned long)+0x4bc (threadLocalAllocBuffer.cpp:216)
V [libjvm.dylib+0x13749ec] VMError::report_and_die(Thread*, void*, char const*, int, char const*, char const*, char*)+0x40
V [libjvm.dylib+0x6aa82c] report_vm_error(char const*, int, char const*, char const*, ...)+0x6c
V [libjvm.dylib+0x12a8754] ThreadLocalAllocBuffer::initialize()+0x7c
V [libjvm.dylib+0xb11194] attach_current_thread(JavaVM_*, void**, void*, bool)+0x1d0
V [libjvm.dylib+0xb10e0c] jni_DestroyJavaVM+0x4c
C [libjli.dylib+0x745c] JavaMain+0xc3c
C [libjli.dylib+0x94cc] ThreadJavaMain+0xc
C [libsystem_pthread.dylib+0x7240] _pthread_start+0x94
This seems timing dependent, only on OSX and G1 we ever noticed an issue (probably JDK-8264798), the FPE_FLTDIV delivered lazily/late.
The suggested fix is to just not sample in this case.