Fix crashes when unbind_for_thread_switch signals an error.
src/eval.c (unbind_for_thread_switch): Accept a 'struct thread_state *' argument and use specpdl_ptr and specpdl of that thread. Fixes crashes if find_symbol_value signals an error. src/thread.c (post_acquire_global_lock): Update current_thread before calling unbind_for_thread_switch. Pass the previous thread to unbind_for_thread_switch.
This commit is contained in:
parent
e57df8f779
commit
bed10876db
4 changed files with 23 additions and 8 deletions
|
@ -1,3 +1,13 @@
|
|||
2013-09-01 Eli Zaretskii <eliz@gnu.org>
|
||||
|
||||
* eval.c (unbind_for_thread_switch): Accept a 'struct
|
||||
thread_state *' argument and use specpdl_ptr and specpdl of that
|
||||
thread. Fixes crashes if find_symbol_value signals an error.
|
||||
|
||||
* thread.c (post_acquire_global_lock): Update current_thread
|
||||
before calling unbind_for_thread_switch. Pass the previous thread
|
||||
to unbind_for_thread_switch.
|
||||
|
||||
2013-08-31 Eli Zaretskii <eliz@gnu.org>
|
||||
|
||||
* systhread.c (sys_cond_init): Set the 'initialized' member to
|
||||
|
|
|
@ -3484,11 +3484,11 @@ unbind_to (ptrdiff_t count, Lisp_Object value)
|
|||
}
|
||||
|
||||
void
|
||||
unbind_for_thread_switch (void)
|
||||
unbind_for_thread_switch (struct thread_state *thr)
|
||||
{
|
||||
union specbinding *bind;
|
||||
|
||||
for (bind = specpdl_ptr; bind != specpdl; --bind)
|
||||
for (bind = thr->m_specpdl_ptr; bind != thr->m_specpdl; --bind)
|
||||
{
|
||||
if (bind->kind >= SPECPDL_LET)
|
||||
{
|
||||
|
|
|
@ -3828,7 +3828,7 @@ extern void set_unwind_protect (ptrdiff_t, void (*) (Lisp_Object), Lisp_Object);
|
|||
extern void set_unwind_protect_ptr (ptrdiff_t, void (*) (void *), void *);
|
||||
extern Lisp_Object unbind_to (ptrdiff_t, Lisp_Object);
|
||||
extern void rebind_for_thread_switch (void);
|
||||
extern void unbind_for_thread_switch (void);
|
||||
extern void unbind_for_thread_switch (struct thread_state *);
|
||||
extern _Noreturn void error (const char *, ...) ATTRIBUTE_FORMAT_PRINTF (1, 2);
|
||||
extern _Noreturn void verror (const char *, va_list)
|
||||
ATTRIBUTE_FORMAT_PRINTF (1, 0);
|
||||
|
|
15
src/thread.c
15
src/thread.c
|
@ -55,15 +55,20 @@ static void
|
|||
post_acquire_global_lock (struct thread_state *self)
|
||||
{
|
||||
Lisp_Object buffer;
|
||||
struct thread_state *prev_thread = current_thread;
|
||||
|
||||
if (self != current_thread)
|
||||
/* Do this early on, so that code below could signal errors (e.g.,
|
||||
unbind_for_thread_switch might) correctly, because we are already
|
||||
running in the context of the thread pointed by SELF. */
|
||||
current_thread = self;
|
||||
|
||||
if (prev_thread != current_thread)
|
||||
{
|
||||
/* CURRENT_THREAD is NULL if the previously current thread
|
||||
/* PREV_THREAD is NULL if the previously current thread
|
||||
exited. In this case, there is no reason to unbind, and
|
||||
trying will crash. */
|
||||
if (current_thread != NULL)
|
||||
unbind_for_thread_switch ();
|
||||
current_thread = self;
|
||||
if (prev_thread != NULL)
|
||||
unbind_for_thread_switch (prev_thread);
|
||||
rebind_for_thread_switch ();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue