Fix critical directory release refcount issue
This commit is contained in:
parent
43629a0b13
commit
292f535a6a
@ -687,11 +687,13 @@ void cleanup_process(process_t * proc, int retval) {
|
||||
if (proc->signal_kstack) {
|
||||
free(proc->signal_kstack);
|
||||
}
|
||||
|
||||
release_directory(proc->thread.page_directory);
|
||||
|
||||
debug_print(INFO, "Dec'ing fds for %d", proc->id);
|
||||
proc->fds->refs--;
|
||||
if (proc->fds->refs == 0) {
|
||||
debug_print(INFO, "Reached 0, all dependencies are closed for %d's file descriptors and page directories", proc->id);
|
||||
release_directory(proc->thread.page_directory);
|
||||
debug_print(INFO, "Going to clear out the file descriptors %d", proc->id);
|
||||
for (uint32_t i = 0; i < proc->fds->length; ++i) {
|
||||
if (proc->fds->entries[i]) {
|
||||
|
24
userspace/tests/test-big-alloc.c
Normal file
24
userspace/tests/test-big-alloc.c
Normal file
@ -0,0 +1,24 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "lib/pthread.h"
|
||||
|
||||
char * x;
|
||||
int i;
|
||||
|
||||
void *print_pid(void * garbage) {
|
||||
printf("x[%d] = %d\n", i, x[i]);
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
printf("Making a big allocation!\n");
|
||||
x = malloc(0x400000);
|
||||
x[0x355555] = 'a';
|
||||
i = atoi(argv[1]);
|
||||
pthread_t thread;
|
||||
pthread_create(&thread, NULL, print_pid, NULL);
|
||||
|
||||
waitpid(thread.id, NULL, 0);
|
||||
return x[i];
|
||||
}
|
Loading…
Reference in New Issue
Block a user