<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class="">Hi Pavel, Jonas,</div><div class=""><br class=""></div><div class="">I was trying to reduce a bug through c-reduce, so I decided to write a SBAPI script to make it easier.</div><div class="">I did find out, that after the first iteration, the reduction gets stuck forever.</div><div class="">I sampled the process and I saw the following (trimmed for readability).</div><div class=""><br class=""></div><div class=""><pre class="c-mrkdwn__pre" data-stringify-type="pre" style="box-sizing: inherit; margin-top: 4px; margin-bottom: 4px; padding: 8px; --saf-0: rgba(var(--sk_foreground_low,29,28,29),0.13); line-height: 1.50001; font-variant-ligatures: none; white-space: pre-wrap; overflow-wrap: break-word; word-break: normal; tab-size: 4; border: 1px solid var(--saf-0); border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; background: rgba(var(--sk_foreground_min,29,28,29),0.04); counter-reset: list-0 0 list-1 0 list-2 0 list-3 0 list-4 0 list-5 0 list-6 0 list-7 0 list-8 0 list-9 0; color: rgb(29, 28, 29); orphans: 2; widows: 2; font-family: Monaco, Menlo, Consolas, "Courier New", monospace !important;">Call graph:<br style="box-sizing: inherit;" class="">[…]<br style="box-sizing: inherit;" class="">                                                            8455 lldb_private::CommandInterpreter::GetScriptInterpreter(bool)  (in _lldb.so) + 84  [0x111aff826]<br style="box-sizing: inherit;" class="">                                                              8455 lldb_private::PluginManager::GetScriptInterpreterForLanguage(lldb::ScriptLanguage, lldb_private::CommandInterpreter&)  (in _lldb.so) + 99  [0x111a1efcf]<br style="box-sizing: inherit;" class="">                                                                8455 lldb_private::ScriptInterpreterPython::CreateInstance(lldb_private::CommandInterpreter&)  (in _lldb.so) + 26  [0x111d128f4]<br style="box-sizing: inherit;" class="">                                                                  8455 std::__1::shared_ptr<lldb_private::ScriptInterpreterPython> std::__1::shared_ptr<lldb_private::ScriptInterpreterPython>::make_shared<lldb_private::CommandInterpreter&>(lldb_private::CommandInterpreter&&&)  (in _lldb.so) + 72  [0x111d1b976]<br style="box-sizing: inherit;" class="">                                                                    8455 lldb_private::ScriptInterpreterPython::ScriptInterpreterPython(lldb_private::CommandInterpreter&)  (in _lldb.so) + 353  [0x111d11ff3]<br style="box-sizing: inherit;" class="">                                                                      8455 lldb_private::ScriptInterpreterPython::InitializePrivate()  (in _lldb.so) + 494  [0x111d12594]<br style="box-sizing: inherit;" class="">                                                                        8455 (anonymous namespace)::InitializePythonRAII::~InitializePythonRAII()  (in _lldb.so) + 146  [0x111d1b446]<br style="box-sizing: inherit;" class="">                                                                          8455 lldb_private::TerminalState::Restore() const  (in _lldb.so) + 74  [0x111ac8268]<br style="box-sizing: inherit;" class="">                                                                            8455 tcsetattr  (in libsystem_c.dylib) + 110  [0x7fff7b95b585]<br style="box-sizing: inherit;" class="">                                                                              8455 ioctl  (in libsystem_kernel.dylib) + 151  [0x7fff7ba19b44]<br style="box-sizing: inherit;" class="">                                                                                8455 __ioctl  (in libsystem_kernel.dylib) + 10  [0x7fff7ba19b5a]<span class="c-mrkdwn__br" data-stringify-type="paragraph-break" style="box-sizing: inherit; display: block; height: unset;"></span></pre></div><div class=""><br class=""></div><div class="">It looks like lldb gets stuck forever in `tcsetattr()`, and there are no other threads waiting so it’s not entirely obvious to me why it’s waiting there.</div><div class="">I was never able to reproduce this with an interactive session, I suspect this is somehow related to the fact that c-reduce spawns a thread in the background, hence it doesn’t have a TTY associated.</div><div class="">I looked at the code that does this, and I wasn’t really able to find a reason why we need to do this work. Jim thinks it might have been needed historically.</div><div class="">`git blame` doesn’t really help that much either. If I remove the code, everything still passes and it’s functional, but before moving forward with this I would like to collect your opinions.</div><div class=""><br class=""></div><div class="">$ git diff</div><div class="">diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp</div><div class="">index ee94a183e0d..c53b3bd0fb6 100644</div><div class="">--- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp</div><div class="">+++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp</div><div class="">@@ -224,10 +224,6 @@ struct InitializePythonRAII {</div><div class=""> public:</div><div class="">   InitializePythonRAII()</div><div class="">       : m_gil_state(PyGILState_UNLOCKED), m_was_already_initialized(false) {</div><div class="">-    // Python will muck with STDIN terminal state, so save off any current TTY</div><div class="">-    // settings so we can restore them.</div><div class="">-    m_stdin_tty_state.Save(STDIN_FILENO, false);</div><div class="">-</div><div class="">     InitializePythonHome();</div><div class=""><br class=""></div><div class=""> #ifdef LLDB_USE_LIBEDIT_READLINE_COMPAT_MODULE</div><div class="">@@ -271,8 +267,6 @@ public:</div><div class="">       // We initialized the threads in this function, just unlock the GIL.</div><div class="">       PyEval_SaveThread();</div><div class="">     }</div><div class="">-</div><div class="">-    m_stdin_tty_state.Restore();</div><div class="">   }</div><div class=""><br class=""></div><div class=""> private:</div></body></html>