[Lldb-commits] [PATCH] D25681: [PseudoTerminal] Fix PseudoTerminal MSVC release crash

Rudy Pons via lldb-commits lldb-commits at lists.llvm.org
Mon Oct 17 08:51:01 PDT 2016

Ilod created this revision.
Ilod added reviewers: zturner, carlokok.
Ilod added a subscriber: lldb-commits.

Since r278177, the Posix functions in PseudoTerminal::OpenFirstAvailableMaster on windows are now inlined LLVM_UNREACHABLE instead of return 0.
This causes __assume(0) to be inlined in OpenFirstAvailableMaster, allowing the optimizer to change code because this function should never be executed. In particular, on Visual 2015 Update 3 Win32 Release builds, the optimizer skips the if (error_str) test, causing a crash if error_str is nullptr.
The added #if !defined(LLDB_DISABLE_POSIX) restore the previous behaviour (which was doing nothing and returning true, as every function was returning 0, and prevent crashes.
The crash was 100% when launching a test x86 executable (built with clang, linked with lld-link) in lldb.
I don't know if there is another fix in progress (not calling the function on Win32?), but it seems to be called from several places, so it may be simpler to fix it in PseudoTerminal.



Index: source/Utility/PseudoTerminal.cpp
--- source/Utility/PseudoTerminal.cpp
+++ source/Utility/PseudoTerminal.cpp
@@ -88,6 +88,7 @@
   if (error_str)
     error_str[0] = '\0';
+#if !defined(LLDB_DISABLE_POSIX)
   // Open the master side of a pseudo terminal
   m_master_fd = ::posix_openpt(oflag);
   if (m_master_fd < 0) {
@@ -111,6 +112,7 @@
     return false;
   return true;

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25681.74853.patch
Type: text/x-patch
Size: 518 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20161017/50a76d57/attachment.bin>

More information about the lldb-commits mailing list