kernel: proc->group may have exited
Handling of thread parents needs to be better... the initial thread of a process can disappear, and with pid reuse it could even be replaced by a different process... this needs to be cleaned up more.
This commit is contained in:
parent
a24baa2b58
commit
bf2c51426d
@ -357,7 +357,7 @@ void arch_dump_traceback(void) {
|
||||
*
|
||||
* @param fromAddr The low address to map, should be page aligned.
|
||||
*/
|
||||
static void map_more_stack(uintptr_t fromAddr) {
|
||||
static int map_more_stack(uintptr_t fromAddr) {
|
||||
volatile process_t * volatile proc = this_core->current_process;
|
||||
|
||||
/* Is this thread the process leader? */
|
||||
@ -365,6 +365,8 @@ static void map_more_stack(uintptr_t fromAddr) {
|
||||
proc = process_from_pid(proc->group);
|
||||
}
|
||||
|
||||
if (!proc) return 0;
|
||||
|
||||
/* Make sure nothing else is going to mess with this process's page tables */
|
||||
spin_lock(proc->image.lock);
|
||||
|
||||
@ -378,6 +380,7 @@ static void map_more_stack(uintptr_t fromAddr) {
|
||||
proc->image.userstack = fromAddr;
|
||||
|
||||
spin_unlock(proc->image.lock);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -520,8 +523,7 @@ static void _page_fault(struct regs * r) {
|
||||
|
||||
/* Quietly map more stack if it was a viable stack address. */
|
||||
if (faulting_address < 0x800000000000 && faulting_address > 0x700000000000) {
|
||||
map_more_stack(faulting_address & 0xFFFFffffFFFFf000);
|
||||
return;
|
||||
if (map_more_stack(faulting_address & 0xFFFFffffFFFFf000)) return;
|
||||
}
|
||||
|
||||
/* Otherwise, segfault the current process. */
|
||||
|
@ -55,6 +55,7 @@ long sys_sbrk(ssize_t size) {
|
||||
if (proc->group != 0) {
|
||||
proc = process_from_pid(proc->group);
|
||||
}
|
||||
if (!proc) return -EINVAL;
|
||||
spin_lock(proc->image.lock);
|
||||
uintptr_t out = proc->image.heap;
|
||||
for (uintptr_t i = out; i < out + size; i += 0x1000) {
|
||||
@ -135,6 +136,7 @@ long sys_sysfunc(long fn, char ** args) {
|
||||
if (!args[0]) return -EFAULT;
|
||||
volatile process_t * volatile proc = this_core->current_process;
|
||||
if (proc->group != 0) proc = process_from_pid(proc->group);
|
||||
if (!proc) return -EFAULT;
|
||||
spin_lock(proc->image.lock);
|
||||
proc->image.heap = (uintptr_t)args[0];
|
||||
spin_unlock(proc->image.lock);
|
||||
@ -149,6 +151,7 @@ long sys_sysfunc(long fn, char ** args) {
|
||||
if (!args) return -EFAULT;
|
||||
volatile process_t * volatile proc = this_core->current_process;
|
||||
if (proc->group != 0) proc = process_from_pid(proc->group);
|
||||
if (!proc) return -EFAULT;
|
||||
spin_lock(proc->image.lock);
|
||||
/* Align inputs */
|
||||
uintptr_t start = ((uintptr_t)args[0]) & 0xFFFFffffFFFFf000UL;
|
||||
|
Loading…
Reference in New Issue
Block a user