Opened 13 years ago

Closed 13 years ago

#7872 closed bug (fixed)

"attempt to acquire spinlock twice on non-SMP system" when setting time

Reported by: scgtrp Owned by: axeld
Priority: normal Milestone: R1
Component: System/Kernel Version: R1/Development
Keywords: Cc: siarzhuk
Blocked By: Blocking:
Platform: All

Description

Calling set_real_time_clock on a uniprocessor system will occasionally cause a kernel panic in per_cpu_real_time_clock_changed. A test program and the panic message it causes are provided below.

#include <sys/time.h>
#include <OS.h>
#include <stdlib.h>
#include <unistd.h>

int main() {
	while (1) {
		set_real_time_clock(rand());
		sleep(1);
	}
}
PANIC: acquire_spinlock: attempt to acquire lock 0x80185b00 twice on non-SMP system (last caller: 0x00000000, value 1)
Welcome to Kernel Debugging Land...
Thread 243 "timetest" running on CPU 0
stack trace for thread 243 "timetest"
    kernel stack: 0x81e1b000 to 0x81e1f000
      user stack: 0x7efef000 to 0x7ffef000
frame               caller     <image>:function + offset
 0 81e1ec24 (+  32) 8011283f   <kernel_x86>:arch_debug_stack_trace + 0x000f
 1 81e1ec44 (+  12) 8011944a   <kernel_x86>:arch_debug_call_with_fault_handler + 0x001b
 2 81e1ec50 (+  48) 8008b1a3   <kernel_x86>:debug_call_with_fault_handler + 0x0053
 3 81e1ec80 (+  80) 8008c21e   <kernel_x86> kernel_debugger_loop(char const*: 0x0 "<NULL>", char const*: 0x1d "<???>", char*: 0x81e1ed10, int32: -2146908690) + 0x014e
 4 81e1ecd0 (+  64) 8008c4f0   <kernel_x86> kernel_debugger_internal(char const*: 0x0 "<NULL>", char const*: 0x0 "<NULL>", char*: 0x81e1ed30, int32: -2146908224) + 0x0060
 5 81e1ed10 (+  32) 8008c7d3   <kernel_x86>:panic + 0x0023
 6 81e1ed30 (+  48) 80067932   <kernel_x86>:acquire_spinlock + 0x00f2
 7 81e1ed60 (+ 112) 8007c428   <kernel_x86>:timer_interrupt + 0x0198
 8 81e1edd0 (+  64) 800553a4   <kernel_x86>:int_io_interrupt_handler + 0x0054
 9 81e1ee10 (+  32) 80116bbd   <kernel_x86> hardware_interrupt(iframe*: 0x81e1ee3c) + 0x011d
10 81e1ee30 (+  12) 8011a3fd   <kernel_x86>:int_bottom + 0x003d
kernel iframe at 0x81e1ee3c (end = 0x81e1ee8c)
 eax 0x0            ebx 0x2             ecx 0x0          edx 0x40
 esi 0x0            edi 0x0             ebp 0x81e1ee94   esp 0x81e1ee70
 eip 0x80128434  eflags 0x13246    
 vector: 0x20, error code: 0x0
11 81e1ee3c (+  88) 80128434   <kernel_x86> pit_set_hardware_timer(int64: 0) + 0x0034
12 81e1ee94 (+  96) 8007c7b2   <kernel_x86> per_cpu_real_time_clock_changed(void*: NULL, int32: 0) + 0x0242
13 81e1eef4 (+  32) 8007be12   <kernel_x86>:timer_real_time_clock_changed + 0x0012
14 81e1ef14 (+  16) 8005fa5b   <kernel_x86> real_time_clock_changed() + 0x000b
15 81e1ef24 (+  32) 8005fdc4   <kernel_x86>:_user_set_real_time_clock + 0x0024
16 81e1ef44 (+ 100) 8011a6a0   <kernel_x86>:handle_syscall + 0x00cd
user iframe at 0x81e1efa8 (end = 0x81e1f000)
 eax 0xaf           ebx 0x2db330        ecx 0x7ffeeefc   edx 0xffff0114
 esi 0x7ffef53c     edi 0x1             ebp 0x7ffeef18   esp 0x81e1efdc
 eip 0xffff0114  eflags 0x3a17     user esp 0x7ffeeefc
 vector: 0x63, error code: 0x0
17 81e1efa8 (+   0) ffff0114   <commpage>:commpage_syscall + 0x0004
18 7ffeef18 (+  32) 002007bd   <timetest>:main + 0x0029
19 7ffeef38 (+  52) 00200643   <timetest>:_start + 0x0053
20 7ffeef6c (+ 112) 00105bef   </boot/system/runtime_loader@0x00100000>:unknown + 0x5bef
21 7ffeefdc (+   0) 7ffeefec   5727:timetest_243_stack@0x7efef000 + 0xffffec

Attachments (1)

disable-interrupts-on-uniprocessor.patch (1.2 KB ) - added by scgtrp 13 years ago.
Disable interrupts even on uniprocessor systems - patch provided by Alex Smith (xyzzy on Freenode)

Download all attachments as: .zip

Change History (5)

comment:1 by scgtrp, 13 years ago

patch: 01

by scgtrp, 13 years ago

Disable interrupts even on uniprocessor systems - patch provided by Alex Smith (xyzzy on Freenode)

comment:2 by siarzhuk, 13 years ago

Cc: siarzhuk added

comment:3 by korli, 13 years ago

Should be fixed in hrev42648. Must have been introduced in hrev42116.

comment:4 by korli, 13 years ago

Resolution: fixed
Status: newclosed

Reverted hrev42648 and applied the patch in hrev42650. Thanks!

Note: See TracTickets for help on using tickets.