bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Port leak when using clisp


From: Flávio Cruz
Subject: [PATCH] Port leak when using clisp
Date: Tue, 25 Aug 2015 23:46:16 +0000

Hi all

I'm trying to port the SBCL compiler to the Hurd but I've found a serious port leak which prevents me from completing the port.

So, the first thing I did was to compile CLISP in order to bootstrap SBCL. CLISP compiled just fine and runs well as far as I know.

Next, I started the bootstrapping process to compile SBCL but it would always fail with a kernel panic since Mach was unable to allocate more slabs for the ipc_port data structure. I figured out that the kernel had thousands of inactive ports (which had a single reference and one send-only right). I wrote a very small script in lisp to reproduce the bug, which simply loads a file several times, like this:

(loop for i from 0 to 100
        do (load "hello-world"))

and the number of inactive ports in the kernel will increase (never reclaimed), even when the CLISP process is killed. I've also attempted to use a separate partition and the ports would still hang around after the ext2fs translator was terminated.

After looking around and using KDB, I've figured out that the following loop in kern/exceptions.c/exception_raise_continue_slow was the culprit:

while (mr == MACH_RCV_INTERRUPTED) {
/*
* Somebody is trying to force this thread
* to a clean point.  We must cooperate
* and then resume the receive.
*/

while (thread_should_halt(self)) {
/* don't terminate while holding a reference */
if (self->ast & AST_TERMINATE)
ipc_port_release(reply_port);
thread_halt_self();
}

ip_lock(reply_port);
....
}

The reply port of the target thread (from CLISP?) is not being released since it enters the while(thread_should_halt(self)) loop and the thread terminates inside thread_halt_self but the previous condition does not hold, which fails to release the port. I also think that once the code enters thread_halt_self, it never comes back since the stack is discarded (for both if cases inside the function).

I've changed the code to make sure the port is released when thread_should_halt is true. So far, the kernel works great and I was finally able to complete the second bootstrapping stage for SBCL. Please see the attached patch and let me know what you think.

Regards
Flavio

Attachment: port-leak.patch
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]