Mercurial > octave
changeset 27690:c81139d8dcc3
prevent atexit functions from adding new atexit functions
* interpreter.h, interpreter.cc (interpreter::m_executing_atexit):
New member variable.
(interpreter::execute_atexit_fcns): Set m_executing_atexit to TRUE.
(interpreter::add_atexit_fcn): Don't add function to list if executing
atexit functions.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 14 Nov 2019 15:21:49 -0500 |
parents | 4f32af6abd4b |
children | fb9258fcf14b |
files | libinterp/corefcn/interpreter.cc libinterp/corefcn/interpreter.h |
diffstat | 2 files changed, 9 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/interpreter.cc Thu Nov 14 15:18:15 2019 -0500 +++ b/libinterp/corefcn/interpreter.cc Thu Nov 14 15:21:49 2019 -0500 @@ -465,6 +465,7 @@ m_in_top_level_repl (false), m_cancel_quit (false), m_executing_finish_script (false), + m_executing_atexit (false), m_initialized (false) { // FIXME: When thread_local storage is used by default, this message @@ -1262,6 +1263,9 @@ void interpreter::execute_atexit_fcns (void) { + // Prevent atexit functions from adding new functions to the list. + m_executing_atexit = true; + while (! m_atexit_fcns.empty ()) { std::string fcn = m_atexit_fcns.front (); @@ -1797,6 +1801,9 @@ void interpreter::add_atexit_fcn (const std::string& fname) { + if (m_executing_atexit) + return; + m_atexit_fcns.push_front (fname); }