[Lldb-commits] [lldb] r234751 - Fix CMICmnStreamStdout::WritePriv which causes a stack overflow (MI)
Ilia K
ki.stfu at gmail.com
Mon Apr 13 07:40:16 PDT 2015
Author: ki.stfu
Date: Mon Apr 13 09:40:16 2015
New Revision: 234751
URL: http://llvm.org/viewvc/llvm-project?rev=234751&view=rev
Log:
Fix CMICmnStreamStdout::WritePriv which causes a stack overflow (MI)
This includes:
* Remove IDS_STDOUT_ERR_NOT_ALL_DATA_WRITTEN enum value
* Remove IDS_STDOUT_ERR_NOT_ALL_DATA_WRITTEN mapped string in CMICmnResources::ms_pResourceId2TextData
* Fix a stack overflow which happens when fputs() fails:
```
[...]
frame #21153: 0x00000001045db6f0 lldb-mi`CMICmnStreamStderr::WritePriv(CMIUtilString const&, CMIUtilString const&, bool) + 416
frame #21154: 0x00000001045db529 lldb-mi`CMICmnStreamStderr::Write(CMIUtilString const&, bool) + 265
frame #21155: 0x00000001045c6a27 lldb-mi`CMICmnBase::SetErrorDescription(CMIUtilString const&) const + 215
frame #21156: 0x00000001045db6f0 lldb-mi`CMICmnStreamStderr::WritePriv(CMIUtilString const&, CMIUtilString const&, bool) + 416
frame #21157: 0x00000001045db529 lldb-mi`CMICmnStreamStderr::Write(CMIUtilString const&, bool) + 265
frame #21158: 0x00000001045c6a27 lldb-mi`CMICmnBase::SetErrorDescription(CMIUtilString const&) const + 215
frame #21159: 0x00000001045db6f0 lldb-mi`CMICmnStreamStderr::WritePriv(CMIUtilString const&, CMIUtilString const&, bool) + 416
frame #21160: 0x00000001045db529 lldb-mi`CMICmnStreamStderr::Write(CMIUtilString const&, bool) + 265
frame #21161: 0x00000001045c6a27 lldb-mi`CMICmnBase::SetErrorDescription(CMIUtilString const&) const + 215
frame #21162: 0x00000001045db6f0 lldb-mi`CMICmnStreamStderr::WritePriv(CMIUtilString const&, CMIUtilString const&, bool) + 416
frame #21163: 0x00000001045db529 lldb-mi`CMICmnStreamStderr::Write(CMIUtilString const&, bool) + 265
frame #21164: 0x00000001045c6a27 lldb-mi`CMICmnBase::SetErrorDescription(CMIUtilString const&) const + 215
frame #21165: 0x00000001045dc540 lldb-mi`CMICmnStreamStdout::WritePriv(CMIUtilString const&, CMIUtilString const&, bool) + 416
frame #21166: 0x00000001045de5fb lldb-mi`CMIDriver::DoMainLoop() + 939
frame #21167: 0x00000001045e2334 lldb-mi`CMIDriverMgr::DriverMainLoop() + 36
frame #21168: 0x00000001045e1a39 lldb-mi`main + 217
frame #21169: 0x00007fff90f395c9 libdyld.dylib`start + 1
```
Modified:
lldb/trunk/tools/lldb-mi/MICmnResources.cpp
lldb/trunk/tools/lldb-mi/MICmnResources.h
lldb/trunk/tools/lldb-mi/MICmnStreamStdout.cpp
Modified: lldb/trunk/tools/lldb-mi/MICmnResources.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmnResources.cpp?rev=234751&r1=234750&r2=234751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmnResources.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmnResources.cpp Mon Apr 13 09:40:16 2015
@@ -176,7 +176,6 @@ const CMICmnResources::SRsrcTextData CMI
{IDS_DRIVER_ERR_MAINLOOP, "Driver. Error in do main loop. %s"},
{IDS_DRIVER_ERR_LOCAL_DEBUG_NOT_IMPL, "Driver. --executable argument given. Local debugging is not implemented."},
{IDS_DRIVER_ERR_LOCAL_DEBUG_INIT, "Driver. --executable argument given. Initialising local debugging failed."},
- {IDS_STDOUT_ERR_NOT_ALL_DATA_WRITTEN, "Stdout. Not all data was written to stream. The data '%s'"},
{IDS_STDERR_ERR_NOT_ALL_DATA_WRITTEN, "Stderr. Not all data was written to stream. The data '%s'"},
{IDS_CMD_ARGS_ERR_N_OPTIONS_REQUIRED, "Command Args. Missing options, %d or more required"},
{IDS_CMD_ARGS_ERR_OPTION_NOT_FOUND, "Command Args. Option '%s' not found"},
Modified: lldb/trunk/tools/lldb-mi/MICmnResources.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmnResources.h?rev=234751&r1=234750&r2=234751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmnResources.h (original)
+++ lldb/trunk/tools/lldb-mi/MICmnResources.h Mon Apr 13 09:40:16 2015
@@ -190,7 +190,6 @@ enum
IDS_DRIVER_WAITING_STDIN_DATA,
- IDS_STDOUT_ERR_NOT_ALL_DATA_WRITTEN,
IDS_STDERR_ERR_NOT_ALL_DATA_WRITTEN,
IDS_CMD_ARGS_ERR_N_OPTIONS_REQUIRED,
Modified: lldb/trunk/tools/lldb-mi/MICmnStreamStdout.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmnStreamStdout.cpp?rev=234751&r1=234750&r2=234751&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmnStreamStdout.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmnStreamStdout.cpp Mon Apr 13 09:40:16 2015
@@ -156,11 +156,9 @@ CMICmnStreamStdout::WritePriv(const CMIU
// Send this text to stdout
const MIint status = ::fputs(vText.c_str(), stdout);
if (status == EOF)
- {
- const CMIUtilString errMsg(CMIUtilString::Format(MIRSRC(IDS_STDOUT_ERR_NOT_ALL_DATA_WRITTEN), vText.c_str()));
- SetErrorDescription(errMsg);
+ // Don't call the CMICmnBase::SetErrorDescription() because it will cause a stack overflow:
+ // CMICmnBase::SetErrorDescription -> CMICmnStreamStdout::Write -> CMICmnStreamStdout::WritePriv -> CMICmnBase::SetErrorDescription
bOk = MIstatus::failure;
- }
else
{
::fprintf(stdout, "\n");
More information about the lldb-commits
mailing list