odd KSE panic

Daniel Eischen eischen at vigrid.com
Fri Jul 2 12:36:25 PDT 2004


On Fri, 2 Jul 2004, Andrew Gallatin wrote:

> 
> I've got a character device which is used for OS-bypass NIC, and I've
> got a problem.. 
> 
> We just started using a second thread in our userland library.  The
> idea is this worker thread ioctls into the driver, where he sleeps
> waiting for an interrupt from the NIC.  When he gets the interrupt,
> he wakes up and returns from the ioctl, where he will process some
> recently completed events.
> 
> The problem happens when exiting.  When main application thread
> decides to exit, it does an ioctl into the driver to wakeup the
> sleeping worker thread.  The worker thread thread wakes up, and then
> exits, then the main thread closes his file descriptor and exits.
> 
> The problem I'm seeing is that I get a panic like the following when
> using KSE.  (A linux binary works fine, ioctls are translated..)
> 
> The interesting thing is that there is no stack..  Just one function
> from my driver (mx_free()) sitting out there by itself.  Is the kernel
> somehow ripping the kernel stacks of all threads out from under them
> when one thread calls exit()?  How do I take a reference so I
> don't risk getting marooned without a stack?

exit() exits the process, including reaping all kernel threads.
I'm not sure why one thread (worker) doing an exit() will
still allow other threads to continue running.  You should
be using pthread_exit() to exit from the worker thread,
but that still doesn't explain why you're having the problem.

I think just calling exit() in the application is sufficient
also.  There's no need to GC the worker thread since the
kernel should take care of all the other threads.

-- 
Dan Eischen



More information about the freebsd-threads mailing list