Hi,After hours of debugging I have discovered a quite nasty issue where seL4_Wait() crash if I build the kernel without optimization (gcc option -O0) on a pc99 tested with qemu.
How to reproduce: Just create an endpoint (from a vka) and call seL4_Wait(). The simplest reproducer can be obtained from the hello-2 tutorial:
- Copy the main.c from the solution directory in the apps/hello-2/src/main.c
- Add the following codes right after the creation of vka (TASK 5, approx line 150):
{
printf("WAITING----------------------------------------------\n");
seL4_Word myBadge;
vka_object_t ep_object = {0};
error = vka_alloc_endpoint(&vka, &ep_object);
ZF_LOGF_IFERR(error, "Failed to allocate new endpoint object.\n");
seL4_Wait(ep_object.cptr, &myBadge);
printf("---------------------------------------------- DONE!!\n");
}
Essentially the added code, creates an endpoint using vka and calls seL4_Wait() on it... I expect the code to block forever since there are no other threads that can unblock it...
- Build it and run it with:
make pc99_hello-2_defconfig
make
make simulate
Expected output:
Booting all finished, dropped to user space
WAITING----------------------------------------------
- Now change the configuration using 'make menuconfig' and select:
seL4 Kernel -> Build Options -> Compiler optimisation flag (-O2)
and change it to -O0, save the new configuration.
- Rebuild and run:
make simulate
Now you get a kernel exception:
WAITING----------------------------------------------
========== KERNEL EXCEPTION ==========
CR2: 0x0 (page-fault address)
CR3: 0x142000 (page-directory physical address)
*0xffaf7e28 == 0xe011a658
*0xffaf7e34 == 0xe011a658
Kernel entry via Interrupt, irq 157
Version info:
- gcc: gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-11)
- qemu: QEMU emulator version 2.0.0, Copyright (c) 2003-2008 Fabrice Bellard
- Build environment: CentOS Linux release 7.3.1611 (Core)
Other info:
- gcc 4.8.5 doesn't seem to support the 'Nehalem' x86 microarchitecture, so I am selecting the 'Generic' microarchitecture (Toolchain Options -> X86 microarchitecture)
- Even the tutorial 'hello-timer' fails exactly with the same exception without any modifications if you build the kernel with -O0.
- Tested on a Beaglebone black: no problems compiling kernel with -O0
Regards,
Fabrizio Bertocci
Real-Time Innovations, Inc.