Opened 7 months ago

Closed 7 months ago

Last modified 6 months ago

#18624 closed bug (fixed)

Kernel panic when a program triggers a floating-point trap

Reported by: bhaible Owned by: nobody
Priority: normal Milestone: R1/beta5
Component: System Version: R1/beta4
Keywords: Cc:
Blocked By: Blocking:
Platform: x86-64

Description

Find attached a program that

1) invokes feenableexcept(FE_INVALID); to turn FE_INVALID floating-point exceptions (not C++ exceptions!) into traps,

2) exercises an arithmetic operation with a signalling NaN, so as to trigger such a FE_INVALID floating-point exception.

How to reproduce:

  • Open a Terminal.
  • Unpack testdir4.tar.gz.
  • Then
    cd testdir4
    ./configure
    make
    make check
    

Expected outcome: The program crashes with some signal (most likely SIGFPE).

Actual outcome: Kernel panic; screenshot attached.

The program invocation that crashes is one of:

gltests/test-snan-2 f
gltests/test-snan-2 d
gltests/test-snan-2 l

Attachments (2)

testdir4.tar.gz (176.9 KB ) - added by bhaible 7 months ago.
test case
fpe-crash.png (49.2 KB ) - added by bhaible 7 months ago.
screenshot of kernel panic

Download all attachments as: .zip

Change History (12)

by bhaible, 7 months ago

Attachment: testdir4.tar.gz added

test case

by bhaible, 7 months ago

Attachment: fpe-crash.png added

screenshot of kernel panic

comment:1 by bhaible, 7 months ago

More details:

gltests/test-snan-2 f succeeds.

gltests/test-snan-2 d succeeds.

gltests/test-snan-2 l is the invocation that crashes.

comment:2 by pulkomandy, 7 months ago

the backtrace goes through x86_unexpected_exception, I think that means we are missing some code to handle these?

comment:3 by waddlesplash, 7 months ago

What hrev, please?

Looks similar to #14802 which was solved by hrev55135.

comment:4 by waddlesplash, 7 months ago

Actually it looks even more similar to #15781.

comment:5 by bhaible, 7 months ago

What hrev, please?

I'm using the release from https://www.haiku-os.org/get-haiku/r1beta4/, download timestamp: 2022-12-22.

comment:6 by X512, 7 months ago

I suspect that exception occurs when kernel write FPU registers during contex switch, some of value is SNaN and triggering exceptions by SNaN is enabled in FPU flags. Kernel should not trust FPU flags set by userland and turn off SNaN exceptions before context switch.

comment:8 by korli, 7 months ago

Milestone: UnscheduledR1/beta5

comment:9 by korli, 7 months ago

Resolution: fixed
Status: newclosed

Fixed in hrev57363

comment:10 by bhaible, 6 months ago

Thanks! I confirm it's fixed in hrev57370.

Note: See TracTickets for help on using tickets.