This is an archive of the discontinued LLVM Phabricator instance.

[lldb] fix cannot convert from 'nullptr' to 'lldb::thread_result_t'
ClosedPublic

Authored by kwk on May 23 2019, 6:02 AM.

Details

Summary

On Windows lldb::thread_result_t resolves to typedef unsigned thread_result_t; and on other platforms it resolves to typedef void *thread_result_t;.
Therefore one cannot use nullptr when returning from a function that returns thread_result_t.

I've made this change because a windows build bot fails with these errors:

FAILED: tools/lldb/source/Core/CMakeFiles/lldbCore.dir/Communication.cpp.obj
C:\PROGRA~2\MICROS~1\2017\COMMUN~1\VC\Tools\MSVC\1416~1.270\bin\Hostx64\x64\cl.exe /nologo /TP -DGTEST_HAS_RTTI=0 -DLLDB_CONFIGURATION_RELEASE -DLLDB_DISABLE_CURSES -DLLDB_DISABLE_LIBEDIT -DLLDB_PYTHON_HOME="\"C:/Program Files (x86)/Microsoft Visual Studio/Shared/Python36_64\"" -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_ENABLE_EXTENDED_ALIGNED_STORAGE -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools\lldb\source\Core -IE:\build_slave\lldb-x64-windows-ninja\llvm\tools\lldb\source\Core -Itools\lldb\include -IE:\build_slave\lldb-x64-windows-ninja\llvm\tools\lldb\include -Iinclude -IE:\build_slave\lldb-x64-windows-ninja\llvm\include -I"C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\Include" -IE:\build_slave\lldb-x64-windows-ninja\llvm\tools\clang\include -Itools\lldb\..\clang\include -IE:\build_slave\lldb-x64-windows-ninja\llvm\tools\lldb\source\. /DWIN32 /D_WINDOWS /Zc:inline /Zc:strictStrings /Oi /Zc:rvalueCast /W4 -wd4141 -wd4146 -wd4180 -wd4244 -wd4258 -wd4267 -wd4291 -wd4345 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd4324 -w14062 -we4238 /MD /O2 /Ob2 /DNDEBUG -wd4018 -wd4068 -wd4150 -wd4201 -wd4251 -wd4521 -wd4530 /EHs-c- /GR- /showIncludes /Fotools\lldb\source\Core\CMakeFiles\lldbCore.dir\Communication.cpp.obj /Fdtools\lldb\source\Core\CMakeFiles\lldbCore.dir\lldbCore.pdb /FS -c E:\build_slave\lldb-x64-windows-ninja\llvm\tools\lldb\source\Core\Communication.cpp
E:\build_slave\lldb-x64-windows-ninja\llvm\tools\lldb\source\Core\Communication.cpp(362): error C2440: 'return': cannot convert from 'nullptr' to 'lldb::thread_result_t'
E:\build_slave\lldb-x64-windows-ninja\llvm\tools\lldb\source\Core\Communication.cpp(362): note: A native nullptr can only be converted to bool or, using reinterpret_cast, to an integral type

and

FAILED: tools/lldb/source/Core/CMakeFiles/lldbCore.dir/Debugger.cpp.obj
C:\PROGRA~2\MICROS~1\2017\COMMUN~1\VC\Tools\MSVC\1416~1.270\bin\Hostx64\x64\cl.exe /nologo /TP -DGTEST_HAS_RTTI=0 -DLLDB_CONFIGURATION_RELEASE -DLLDB_DISABLE_CURSES -DLLDB_DISABLE_LIBEDIT -DLLDB_PYTHON_HOME="\"C:/Program Files (x86)/Microsoft Visual Studio/Shared/Python36_64\"" -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_ENABLE_EXTENDED_ALIGNED_STORAGE -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools\lldb\source\Core -IE:\build_slave\lldb-x64-windows-ninja\llvm\tools\lldb\source\Core -Itools\lldb\include -IE:\build_slave\lldb-x64-windows-ninja\llvm\tools\lldb\include -Iinclude -IE:\build_slave\lldb-x64-windows-ninja\llvm\include -I"C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\Include" -IE:\build_slave\lldb-x64-windows-ninja\llvm\tools\clang\include -Itools\lldb\..\clang\include -IE:\build_slave\lldb-x64-windows-ninja\llvm\tools\lldb\source\. /DWIN32 /D_WINDOWS /Zc:inline /Zc:strictStrings /Oi /Zc:rvalueCast /W4 -wd4141 -wd4146 -wd4180 -wd4244 -wd4258 -wd4267 -wd4291 -wd4345 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd4324 -w14062 -we4238 /MD /O2 /Ob2 /DNDEBUG -wd4018 -wd4068 -wd4150 -wd4201 -wd4251 -wd4521 -wd4530 /EHs-c- /GR- /showIncludes /Fotools\lldb\source\Core\CMakeFiles\lldbCore.dir\Debugger.cpp.obj /Fdtools\lldb\source\Core\CMakeFiles\lldbCore.dir\lldbCore.pdb /FS -c E:\build_slave\lldb-x64-windows-ninja\llvm\tools\lldb\source\Core\Debugger.cpp
E:\build_slave\lldb-x64-windows-ninja\llvm\tools\lldb\source\Core\Debugger.cpp(1619): error C2440: 'return': cannot convert from 'nullptr' to 'lldb::thread_result_t'
E:\build_slave\lldb-x64-windows-ninja\llvm\tools\lldb\source\Core\Debugger.cpp(1619): note: A native nullptr can only be converted to bool or, using reinterpret_cast, to an integral type
E:\build_slave\lldb-x64-windows-ninja\llvm\tools\lldb\source\Core\Debugger.cpp(1664): error C2440: 'return': cannot convert from 'nullptr' to 'lldb::thread_result_t'
E:\build_slave\lldb-x64-windows-ninja\llvm\tools\lldb\source\Core\Debugger.cpp(1664): note: A native nullptr can only be converted to bool or, using reinterpret_cast, to an integral type

This is the failing build: http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/5035/steps/build/logs/stdio

Diff Detail

Repository
rLLDB LLDB

Event Timeline

kwk created this revision.May 23 2019, 6:02 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 23 2019, 6:02 AM
labath added a subscriber: labath.May 23 2019, 6:08 AM

returning lldb::thread_result_t() is probably the best thing to do here...

kwk updated this revision to Diff 200951.May 23 2019, 6:12 AM

Fixed second place where nullptr couldn't be converted

kwk edited the summary of this revision. (Show Details)May 23 2019, 6:13 AM
kwk updated this revision to Diff 200953.May 23 2019, 6:15 AM

Return lldb::thread_result_t() instead of NULL

kwk added a comment.May 23 2019, 6:16 AM

returning lldb::thread_result_t() is probably the best thing to do here...

@labath I've followed your advice. Running tests for linux now.

labath accepted this revision.May 23 2019, 6:17 AM
This revision is now accepted and ready to land.May 23 2019, 6:17 AM

returning lldb::thread_result_t() is probably the best thing to do here...

I would say return {}; is the best one, it has 118 uses in lldb/.

returning lldb::thread_result_t() is probably the best thing to do here...

I would say return {}; is the best one, it has 118 uses in lldb/.

Yeah, that works too...

kwk edited the summary of this revision. (Show Details)May 23 2019, 6:55 AM
clayborg accepted this revision.May 23 2019, 7:12 AM
kwk updated this revision to Diff 200969.May 23 2019, 7:21 AM
  • Return empty lldb::thread_result_t as {}
This revision was automatically updated to reflect the committed changes.

It looks like this was not enough and the build is still broken. Please revert your change or fix it and then keep an eye on the Buildbot to make sure it turns to green again. Once it's broken, it won't continue sending failure emails, so you have to monitor it to make sure your change fixed it.