[Top][All Lists]

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

Re: [PATCH] Support threads in modules

From: Philipp Stephani
Subject: Re: [PATCH] Support threads in modules
Date: Sun, 11 Jun 2017 13:25:54 +0000

Philipp Stephani <address@hidden> schrieb am Sa., 10. Juni 2017 um 21:58 Uhr:

Once again: there _are_ legitimate situations in Emacs when for a
short time current_thread is NULL.  If you assume that these
situations don't happen, your code will sooner or later crash and
burn.  I'm saying this because I once thought current_thread should be
non-NULL at all times, and my code which assumed that did crash.

I've reviewed the threads code, and I'm quite sure that current_thread can never be NULL during check_thread. current_thread is only NULL between exiting a Lisp thread and resuming execution in another thread after reacquiring the GIL. The evaluator doesn't run during that phase, and therefore no module functions can run.
current_thread could only be NULL during check_thread if called from a thread that is not a Lisp thread (i.e. an OS thread created by the module). That's exactly one of the undefined behavior situations that the assertions are meant to prevent.

Here's a new patch, which implements option (1). 

Attachment: 0001-Support-threads-in-modules.txt
Description: Text document

reply via email to

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