diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-07-04 19:34:19 +0300 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-07-04 19:34:19 +0300 |
| commit | b82479a69cd6110c9099031e133fda62f8e11222 (patch) | |
| tree | 8fe281f23c0b1c6e8f88a96fd68606157f03c9a1 | |
| parent | 07c2376702fb3d508d6ffad6b0ce93b83972ad6e (diff) | |
| download | kmi-b82479a69cd6110c9099031e133fda62f8e11222.tar.gz kmi-b82479a69cd6110c9099031e133fda62f8e11222.zip | |
add note about orphaning running threads
| -rw-r--r-- | src/tcb.c | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -214,6 +214,7 @@ static stat_t __destroy_thread_data(struct tcb *t) /* forcefully free last struggling bits of memory */ destroy_uvmem(t); + destroy_vmem(t->proc.vmem); /* free associated kernel stack and the structure itself */ vm_t bottom = align_down((vm_t)t, order_size(MM_O0)); @@ -247,11 +248,20 @@ stat_t destroy_proc(struct tcb *p) hard_assert(tcbs, ERR_NOINIT); hard_assert(is_proc(p), ERR_INVAL); + /** @todo currently we don't care who else is in the address space when + * we start freeing stuff, one fairly simple way to deal with this is to + * just not care. A thread that tries to access some bit of freed memory + * will cause a segfault (eventually at least), and we can just check in + * the segfault handler if the thread has become orphaned. + * Currently no segfault handler exists, though. */ + p->dead = true; /* unreference ourselves */ unreference_proc(p); - catastrophic_assert(destroy_uvmem(p)); + /* clear all privately owned memory regions, keep shared ones alive for + * now */ + clear_uvmem(p); /* don't destroy thread data just yet, let the thread destroy itself * later */ |
