Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic when compiling python #140

Open
heatd opened this issue Oct 4, 2024 · 2 comments
Open

Panic when compiling python #140

heatd opened this issue Oct 4, 2024 · 2 comments

Comments

@heatd
Copy link
Owner

heatd commented Oct 4, 2024


Thread 4 (Thread 1.4 (CPU#3 [halted ])):
#0  sched_idle (ptr=0x0 <abi::abi_data>) at kernel/sched/scheduler.cpp:503
#1  0x0000000000000000 in ?? ()

Thread 3 (Thread 1.3 (CPU#2 [running])):
#0  spin_lock_slow_path (lock=0xffff807f15911400, what_to_insert=3) at kernel/spinlock.cpp:47
#1  0xffffffff81100488 in spin_lock_irqsave (lock=<optimized out>) at include/onyx/spinlock.h:67
#2  __sched_find_next (cpu=2) at kernel/sched/scheduler.cpp:224
#3  0xffffffff811009c0 in sched_find_next () at include/onyx/smp.h:85
#4  sched_find_runnable () at kernel/sched/scheduler.cpp:275
#5  sched_schedule (last_stack=last_stack@entry=0xffff807f27ca8d18) at kernel/sched/scheduler.cpp:459
#6  0xffffffff81100a9a in sched_schedule (last_stack=0xffff807f27ca8d18) at kernel/sched/scheduler.cpp:413
#7  0xffffffff81113051 in platform_yield () at arch/x86_64/interrupts.S:538
#8  0xffffffff81100f82 in sched_yield () at kernel/sched/scheduler.cpp:671
#9  0xffffffff810315a5 in futex::futex_queue::wait (this=0xffff807f27ca8eb0, s=0xffffffff811d644c <futex::futex_hashtable_locks+3084>) at kernel/futex.cpp:121
#10 futex::wait (uaddr=<optimized out>, val=<optimized out>, flags=<optimized out>, utimespec=<optimized out>) at kernel/futex.cpp:331
#11 0xffffffff81031fe1 in sys_futex (uaddr=<optimized out>, futex_op=<optimized out>, val=<optimized out>, timeout=<optimized out>, uaddr2=<optimized out>, val3=<optimized out>) at kernel/futex.cpp:522
#12 0xffffffff810446d9 in __sys_futex_thunk (arg0=<optimized out>, arg1=<optimized out>, arg2=<optimized out>, arg3=<optimized out>, arg4=<optimized out>, arg5=<optimized out>, arg6=68) at kernel/syscall_thunk.cpp:547
#13 0xffffffff81118452 in do_syscall64 (frame=0xffff807f27ca8f78) at arch/x86_64/syscall.cpp:44
#14 0xffffffff811120cf in syscall_ENTRY64 () at arch/x86_64/entry.S:130
#15 0x0000000000000033 in abi::abi_data ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)

Thread 2 (Thread 1.2 (CPU#1 [halted ])):
#0  sched_idle (ptr=0x0 <abi::abi_data>) at kernel/sched/scheduler.cpp:503
#1  0x0000000000000000 in ?? ()

Thread 1 (Thread 1.1 (CPU#0 [halted ])):
#0  halt () at arch/x86_64/debug.cpp:15
#1  0xffffffff81035936 in panic (msg=msg@entry=0xffffffff81161540 "Assertion %s failed in %s:%u, in function %s\n") at kernel/panic.cpp:95
#2  0xffffffff8103596b in __assert_fail (assertion=<optimized out>, file=<optimized out>, line=<optimized out>, function=<optimized out>) at kernel/panic.cpp:141
#3  0xffffffff8103411f in vprintf(const char * __restrict__, typedef __va_list_tag __va_list_tag *) (format=0xffffffff81170224 "panic: %s\n", va=va@entry=0xffff807f27ca2968) at kernel/kernlog.cpp:348
#4  0xffffffff810342cb in vprintk (format=<optimized out>, ap=0xffff807f27ca2968) at kernel/kernlog.cpp:311
#5  printk(const char * __restrict__, ...) (format=<optimized out>) at kernel/kernlog.cpp:319
#6  0xffffffff810358e1 in panic (msg=msg@entry=0xffffffff81161540 "Assertion %s failed in %s:%u, in function %s\n") at kernel/panic.cpp:125
#7  0xffffffff8103596b in __assert_fail (assertion=<optimized out>, file=<optimized out>, line=<optimized out>, function=<optimized out>) at kernel/panic.cpp:141
#8  0xffffffff8110183f in __thread_wake_up (thread=0xffff807f26c21800, cpu=0) at kernel/sched/scheduler.cpp:935
#9  0xffffffff811018bd in thread_wake_up (thread=0xffff807f26c21800) at kernel/sched/scheduler.cpp:987
#10 0xffffffff810418d8 in wait_queue_wake_all (queue=0xffff807f169eded0) at kernel/wait_queue.cpp:82
#11 0xffffffff81031928 in futex::futex_queue::wake (this=<optimized out>) at kernel/futex.cpp:131
#12 futex::wake (uaddr=<optimized out>, flags=<optimized out>, to_wake=1) at kernel/futex.cpp:381
#13 0xffffffff81031fa3 in sys_futex (uaddr=<optimized out>, futex_op=<optimized out>, val=<optimized out>, timeout=<optimized out>, uaddr2=<optimized out>, val3=<optimized out>) at kernel/futex.cpp:524
#14 0xffffffff810446d9 in __sys_futex_thunk (arg0=<optimized out>, arg1=<optimized out>, arg2=<optimized out>, arg3=<optimized out>, arg4=<optimized out>, arg5=<optimized out>, arg6=0) at kernel/syscall_thunk.cpp:547
#15 0xffffffff81118452 in do_syscall64 (frame=0xffff807f27ca2f78) at arch/x86_64/syscall.cpp:44
--Type <RET> for more, q to quit, c to continue without paging--
#16 0xffffffff811120cf in syscall_ENTRY64 () at arch/x86_64/entry.S:130
#17 0x0000000000000033 in abi::abi_data ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
@heatd
Copy link
Owner Author

heatd commented Oct 4, 2024

I think this is because thread migration is a little fucked when it comes to locking. sched_lock definitely needs a

for (;;)
{
    unsigned int cpu = READ_ONCE(thread->cpu);
    spin_lock(/*cpu->scheduler_lock*/);
    spin_lock(&thread->lock);
    if (thread->cpu == cpu)
       break;
   /* unlock locks, retry */
}

As to making sure a thread doesn't get migrated twice... Dunno. Is it an issue? Probably not? As long as we assume thread->cpu can change at any point in time (aka READ_ONCE)

@heatd
Copy link
Owner Author

heatd commented Oct 4, 2024

or maybe ->cpu should get switched out while holding the thread's sched locks (needing a separate sched_unlock function for that)...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant