Opened 14 months ago

Closed 14 months ago

Last modified 13 months ago

#14160 closed bug (fixed)

Haiku x86_64 built with GCC 7.3 KDLs on startup

Reported by: waddlesplash Owned by: bonefish
Priority: normal Milestone: Unscheduled
Component: Build System Version: R1/Development
Keywords: Cc: korli, kallisti5
Blocked By: Blocking:
Has a Patch: no Platform: All

Description

e.g. https://keybase.pub/kallisti5/Screenshots/gpe.png

kallisti5 says this happens on QEMU-KVM but not QEMU (without KVM.)

If you want to build your own GCC 7.3 Haiku:

Attachments (3)

x86_64 (4.5 KB) - added by waddlesplash 14 months ago.
should have sha256sum 79ad0dd02282cf4d06aeb3f0df7a91a053ca23c1bf676535c625f8992ef348bd
gcc7.png (140.8 KB) - added by kallisti5 14 months ago.
Running tests... gcc7 builds seem ok so far.
gpe.png (27.4 KB) - added by korli 14 months ago.
KDL screenshot

Download all attachments as: .zip

Change History (13)

Changed 14 months ago by waddlesplash

Attachment: x86_64 added

should have sha256sum 79ad0dd02282cf4d06aeb3f0df7a91a053ca23c1bf676535c625f8992ef348bd

comment:1 Changed 14 months ago by waddlesplash

Linux kernel makefile has these:

# clang sets -fmerge-all-constants by default as optimization, but this
# is non-conforming behavior for C and in fact breaks the kernel, so we
# need to disable it here generally.
KBUILD_CFLAGS	+= $(call cc-option,-fno-merge-all-constants)

# for gcc -fno-merge-all-constants disables everything, but it is fine
# to have actual conforming behavior enabled.
KBUILD_CFLAGS	+= $(call cc-option,-fmerge-constants)

# Make sure -fstack-check isn't enabled (like gentoo apparently did)
KBUILD_CFLAGS  += $(call cc-option,-fno-stack-check,)

Related?

comment:2 Changed 14 months ago by waddlesplash

Actually looking at https://gcc.gnu.org/gcc-6/porting_to.html it might be the lifetime-dse one, based on https://bugzilla.redhat.com/show_bug.cgi?id=1316999 and other comments about C++ code.

comment:3 Changed 14 months ago by waddlesplash

The panic only occurs with -O2; with -O1 there is no panic.

Last edited 14 months ago by waddlesplash (previous) (diff)

comment:4 Changed 14 months ago by waddlesplash

The culprit pass is rtl-stv1. If you disable it using -fdisable-rtl-stv1 on the whole kernel, the KDL goes away.

comment:5 Changed 14 months ago by waddlesplash

Minimum patch/workaround:

diff --git a/src/system/kernel/Jamfile b/src/system/kernel/Jamfile
index 7964320883..10f61bd224 100644
--- a/src/system/kernel/Jamfile
+++ b/src/system/kernel/Jamfile
@@ -75,6 +75,10 @@ KernelMergeObject kernel_core.o :
        : $(TARGET_KERNEL_PIC_CCFLAGS)
 ;
 
+if $(HAIKU_GCC_VERSION_$(HAIKU_ARCH)[1]) >= 7 {
+       ObjectC++Flags commpage.o signal.o thread.o : -fdisable-rtl-stv1 ;
+}
+
 # Generate the header defining macros for C++ structure sizes.
 local kernelC++StructSizesHeader = [ FGristFiles kernel_c++_struct_sizes.h ] ;
 TARGET_HDRS_$(TARGET_PACKAGING_ARCH) on $(kernelC++StructSizesHeader)

I've tried a few permutations of those by themselves, but as far as I can tell, you need all 3 in order for the KDL to be fixed.

comment:6 Changed 14 months ago by waddlesplash

And the proposed comment for that if:

	# With the rtl-stv1 pass on these files, the kernel panics towards the end
	# of the boot process with a "General Protection Exception", see
	# https://dev.haiku-os.org/ticket/14160. The pass itself vectorizes
	# a significant number of otherwise-scalar operations, which may be why
	# disabling it fixes the problem.
	#
	# At time of writing, GCC does not seem to have a way to disable
	# vectorization as a result of optimization without disabling
	# FPU usage altogether, which of course is not what we want and
	# breaks when using libstdc++'s headers anyway.

comment:7 Changed 14 months ago by waddlesplash

Added in hrev51968.

comment:8 Changed 14 months ago by korli

Please attach kdl screenshot to the bug tracker.

It would be nice to point to the documentation reference for the GCC flag.

Changed 14 months ago by kallisti5

Attachment: gcc7.png added

Running tests... gcc7 builds seem ok so far.

Changed 14 months ago by korli

Attachment: gpe.png added

KDL screenshot

comment:9 Changed 14 months ago by waddlesplash

Resolution: fixed
Status: newclosed

Fixed (for now at least) by that commit.

comment:10 Changed 13 months ago by waddlesplash

Actual fix pushed in hrev52020.

Note: See TracTickets for help on using tickets.