Fix critical directory release refcount issue

This commit is contained in:
Kevin Lange 2015-11-05 22:18:49 -08:00
parent 43629a0b13
commit 292f535a6a
2 changed files with 27 additions and 1 deletions

View File

@ -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]) {

View 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];
}