Skip to contentSkip to conversation

Question about Kernel Reporting Sigfaults in <arch>/mm/fault.c

DISCUSSION Sean Kamath 2 participants 2 messages Jul 6, 2006 – Jul 7, 2006

lore
Share & tools
lore
#0 lore raw

Hi.

[All lines are from 2.6.16's latest git repository from kernel.org.]

We recently started noticing error messages showing up in the messages file every time a user process segfaulted. Doing some investigation, it turns out it's only on x86_64 boxen (the other boxes are i386). We traced this down to arch/x86_64/mm/fault.c:do_page_fault() (under bad_area_nosemaphore):

478 if (exception_trace && unhandled_signal(tsk, SIGSEGV)) {
479 printk(
480 "%s%s[%d]: segfault at %016lx rip %016lx rsp %016lx error %lx\n",
481 tsk->pid > 1 ? KERN_INFO : KERN_EMERG,
482 tsk->comm, tsk->pid, address, regs->rip,
483 regs->rsp, error_code);
484 }

exception_trace is set to 1 (line 296) and not used anywhere else in the file.

arch/i386/mm/fault.c does not have this.
arch/sparc64/mm/fault.c does not have this.

Oddly, sparc/mm/fault.c *does* have (a version of) this, only ifdef'ed out:

319 #if 0
320 printk("Fault whee %s [%d]: segfaults at %08lx pc=%08lx\n",
321 tsk->comm, tsk->pid, address, regs->pc);
322 #endif

This leads me to suspect that the segfault reporting in in x86_64 is vestigial from a time when it was helpful.

The question(s): Is this intentional (to have segfaults reported on x86_64, and (possibly) nothing else)? Or was "exception_trace" supposed to be a flag but never fleshed out?

I admit, it would be nice to be able to toggle on and off segfault reporting in the kernel (from a system administration point of view, this is helpful to be able to go back to developers and say 'your program is crashing a lot' -- something necessary if you are protecting end-users from a lot of core files . . .) on all platforms.

Sean

#1 lore raw
Quoted 3 lines · Sean Kamath

exception_trace is set to 1 (line 296) and not used anywhere else in the file.

It can be set using /proc/sys/debug/exception-trace

Quoted 1 line

The question(s): Is this intentional (to have segfaults reported on x86_64,

Yes.

Quoted 5 lines

I admit, it would be nice to be able to toggle on and off segfault reporting in the kernel (from a system administration point of view, this is helpful to be able to go back to developers and say 'your program is crashing a lot' -- something necessary if you are protecting end-users from a lot of core files . . .) on all platforms.

It was originally was added when the port was still young to debug user land faster, but it keeps people honest and is still very useful.

In fact it found some long standing bugs that were never noticed on i386 with programs silently segfaulting.

-Andi