-
Notifications
You must be signed in to change notification settings - Fork 0
Enabling out-of-process JIT execution in CppInterOp #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Vipul-Cariappa
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good. I will give a more detailed review in some time. Could you please address the things I have already mentioned in the other PR from your repo.
Vipul-Cariappa
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a few things to discuss.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
| size_t newLen = | ||
| fread(content.get(), sizeof(char), bufsize, m_TempFile.get()); | ||
| if (ferror(m_TempFile.get()) != 0) | ||
| size_t newLen = fread(content.get(), sizeof(char), bufsize, m_TempFile); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: The 1st argument to 'fread' is a buffer with size 0 but should be a buffer with size equal to or greater than the value of the 2nd argument (which is 1) times the 3rd argument (which is 18446744073709551615) [clang-analyzer-unix.StdCLibraryFunctions]
size_t newLen = fread(content.get(), sizeof(char), bufsize, m_TempFile);
^Additional context
lib/CppInterOp/CppInterOp.cpp:3966: Calling 'StreamCaptureInfo::GetCapturedString'
std::string result = SCI.GetCapturedString();
^lib/CppInterOp/CppInterOp.cpp:3913: Taking false branch
if (dup2(m_DupFD, m_FD) < 0)
^lib/CppInterOp/CppInterOp.cpp:3916: Taking false branch
if (fseek(m_TempFile, 0L, SEEK_END) != 0)
^lib/CppInterOp/CppInterOp.cpp:3920: Assuming that 'ftell' fails
long bufsize = ftell(m_TempFile);
^lib/CppInterOp/CppInterOp.cpp:3920: 'bufsize' initialized here
long bufsize = ftell(m_TempFile);
^lib/CppInterOp/CppInterOp.cpp:3921: Taking true branch
if (bufsize == -1)
^lib/CppInterOp/CppInterOp.cpp:3925: Storing uninitialized value
std::unique_ptr<char[]> content(new char[bufsize + 1]);
^lib/CppInterOp/CppInterOp.cpp:3925: Passing value via 1st parameter '__p'
std::unique_ptr<char[]> content(new char[bufsize + 1]);
^lib/CppInterOp/CppInterOp.cpp:3925: Calling constructor for 'unique_ptr<char[], std::default_delete<char[]>>'
std::unique_ptr<char[]> content(new char[bufsize + 1]);
^/usr/include/c++/13/bits/unique_ptr.h:603: Calling constructor for '__uniq_ptr_data<char, std::default_delete<char[]>, true, true>'
: _M_t(__p)
^/usr/include/c++/13/bits/unique_ptr.h:603: Passing '' via 1st parameter '__p'
: _M_t(__p)
^/usr/include/c++/13/bits/unique_ptr.h:603: Calling constructor for '__uniq_ptr_impl<char, std::default_delete<char[]>>'
: _M_t(__p)
^/usr/include/c++/13/bits/unique_ptr.h:175: Calling '__uniq_ptr_impl::_M_ptr'
__uniq_ptr_impl(pointer __p) : _M_t() { _M_ptr() = __p; }
^/usr/include/c++/13/bits/unique_ptr.h:196: Calling 'get<0UL, char *, std::default_delete<char[]>>'
pointer& _M_ptr() noexcept { return std::get<0>(_M_t); }
^/usr/include/c++/13/tuple:1803: Calling '__get_helper<0UL, char *, std::default_delete<char[]>>'
{ return std::__get_helper<__i>(__t); }
^/usr/include/c++/13/tuple:1787: Calling '_Tuple_impl::_M_head'
{ return _Tuple_impl<__i, _Head, _Tail...>::_M_head(__t); }
^/usr/include/c++/13/tuple:268: Calling '_Head_base::_M_head'
_M_head(_Tuple_impl& __t) noexcept { return _Base::_M_head(__t); }
^/usr/include/c++/13/tuple:268: Returning from '_Head_base::_M_head'
_M_head(_Tuple_impl& __t) noexcept { return _Base::_M_head(__t); }
^/usr/include/c++/13/tuple:1787: Returning from '_Tuple_impl::_M_head'
{ return _Tuple_impl<__i, _Head, _Tail...>::_M_head(__t); }
^/usr/include/c++/13/tuple:1803: Returning from '__get_helper<0UL, char *, std::default_delete<char[]>>'
{ return std::__get_helper<__i>(__t); }
^/usr/include/c++/13/bits/unique_ptr.h:196: Returning from 'get<0UL, char *, std::default_delete<char[]>>'
pointer& _M_ptr() noexcept { return std::get<0>(_M_t); }
^/usr/include/c++/13/bits/unique_ptr.h:175: Returning from '__uniq_ptr_impl::_M_ptr'
__uniq_ptr_impl(pointer __p) : _M_t() { _M_ptr() = __p; }
^/usr/include/c++/13/bits/unique_ptr.h:175: The value of '__p' is assigned to 'content._M_t._M_t._M_head_impl'
__uniq_ptr_impl(pointer __p) : _M_t() { _M_ptr() = __p; }
^/usr/include/c++/13/bits/unique_ptr.h:603: Returning from constructor for '__uniq_ptr_impl<char, std::default_delete<char[]>>'
: _M_t(__p)
^/usr/include/c++/13/bits/unique_ptr.h:603: Returning from constructor for '__uniq_ptr_data<char, std::default_delete<char[]>, true, true>'
: _M_t(__p)
^lib/CppInterOp/CppInterOp.cpp:3925: Returning from constructor for 'unique_ptr<char[], std::default_delete<char[]>>'
std::unique_ptr<char[]> content(new char[bufsize + 1]);
^lib/CppInterOp/CppInterOp.cpp:3928: Taking false branch
if (fseek(m_TempFile, 0L, SEEK_SET) != 0)
^lib/CppInterOp/CppInterOp.cpp:3932: The 1st argument to 'fread' is a buffer with size 0 but should be a buffer with size equal to or greater than the value of the 2nd argument (which is 1) times the 3rd argument (which is 18446744073709551615)
size_t newLen = fread(content.get(), sizeof(char), bufsize, m_TempFile);
^| size_t newLen = | ||
| fread(content.get(), sizeof(char), bufsize, m_TempFile.get()); | ||
| if (ferror(m_TempFile.get()) != 0) | ||
| size_t newLen = fread(content.get(), sizeof(char), bufsize, m_TempFile); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "fread" is directly included [misc-include-cleaner]
size_t newLen = fread(content.get(), sizeof(char), bufsize, m_TempFile);
^| } | ||
|
|
||
| #ifndef _WIN32 | ||
| pid_t GetExecutorPID() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "pid_t" is directly included [misc-include-cleaner]
lib/CppInterOp/CppInterOp.cpp:40:
- #if CLANG_VERSION_MAJOR >= 19
+ #include <sys/types.h>
+ #if CLANG_VERSION_MAJOR >= 19| struct FileDeleter { | ||
| void operator()(FILE* f) { | ||
| if (f) | ||
| fclose(f); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: calling legacy resource function without passing a 'gsl::owner<>' [cppcoreguidelines-owning-memory]
fclose(f);
^There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
| size_t newLen = | ||
| fread(content.get(), sizeof(char), bufsize, m_TempFile.get()); | ||
| if (ferror(m_TempFile.get()) != 0) | ||
| size_t newLen = fread(content.get(), sizeof(char), bufsize, m_TempFile); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: The 1st argument to 'fread' is a buffer with size 0 but should be a buffer with size equal to or greater than the value of the 2nd argument (which is 1) times the 3rd argument (which is 18446744073709551615) [clang-analyzer-unix.StdCLibraryFunctions]
size_t newLen = fread(content.get(), sizeof(char), bufsize, m_TempFile);
^Additional context
lib/CppInterOp/CppInterOp.cpp:3965: Calling 'StreamCaptureInfo::GetCapturedString'
std::string result = SCI.GetCapturedString();
^lib/CppInterOp/CppInterOp.cpp:3913: Taking false branch
if (dup2(m_DupFD, m_FD) < 0)
^lib/CppInterOp/CppInterOp.cpp:3916: Taking false branch
if (fseek(m_TempFile, 0L, SEEK_END) != 0)
^lib/CppInterOp/CppInterOp.cpp:3920: Assuming that 'ftell' fails
long bufsize = ftell(m_TempFile);
^lib/CppInterOp/CppInterOp.cpp:3920: 'bufsize' initialized here
long bufsize = ftell(m_TempFile);
^lib/CppInterOp/CppInterOp.cpp:3921: Taking true branch
if (bufsize == -1)
^lib/CppInterOp/CppInterOp.cpp:3925: Storing uninitialized value
std::unique_ptr<char[]> content(new char[bufsize + 1]);
^lib/CppInterOp/CppInterOp.cpp:3925: Passing value via 1st parameter '__p'
std::unique_ptr<char[]> content(new char[bufsize + 1]);
^lib/CppInterOp/CppInterOp.cpp:3925: Calling constructor for 'unique_ptr<char[], std::default_delete<char[]>>'
std::unique_ptr<char[]> content(new char[bufsize + 1]);
^/usr/include/c++/13/bits/unique_ptr.h:603: Calling constructor for '__uniq_ptr_data<char, std::default_delete<char[]>, true, true>'
: _M_t(__p)
^/usr/include/c++/13/bits/unique_ptr.h:603: Passing '' via 1st parameter '__p'
: _M_t(__p)
^/usr/include/c++/13/bits/unique_ptr.h:603: Calling constructor for '__uniq_ptr_impl<char, std::default_delete<char[]>>'
: _M_t(__p)
^/usr/include/c++/13/bits/unique_ptr.h:175: Calling '__uniq_ptr_impl::_M_ptr'
__uniq_ptr_impl(pointer __p) : _M_t() { _M_ptr() = __p; }
^/usr/include/c++/13/bits/unique_ptr.h:196: Calling 'get<0UL, char *, std::default_delete<char[]>>'
pointer& _M_ptr() noexcept { return std::get<0>(_M_t); }
^/usr/include/c++/13/tuple:1803: Calling '__get_helper<0UL, char *, std::default_delete<char[]>>'
{ return std::__get_helper<__i>(__t); }
^/usr/include/c++/13/tuple:1787: Calling '_Tuple_impl::_M_head'
{ return _Tuple_impl<__i, _Head, _Tail...>::_M_head(__t); }
^/usr/include/c++/13/tuple:268: Calling '_Head_base::_M_head'
_M_head(_Tuple_impl& __t) noexcept { return _Base::_M_head(__t); }
^/usr/include/c++/13/tuple:268: Returning from '_Head_base::_M_head'
_M_head(_Tuple_impl& __t) noexcept { return _Base::_M_head(__t); }
^/usr/include/c++/13/tuple:1787: Returning from '_Tuple_impl::_M_head'
{ return _Tuple_impl<__i, _Head, _Tail...>::_M_head(__t); }
^/usr/include/c++/13/tuple:1803: Returning from '__get_helper<0UL, char *, std::default_delete<char[]>>'
{ return std::__get_helper<__i>(__t); }
^/usr/include/c++/13/bits/unique_ptr.h:196: Returning from 'get<0UL, char *, std::default_delete<char[]>>'
pointer& _M_ptr() noexcept { return std::get<0>(_M_t); }
^/usr/include/c++/13/bits/unique_ptr.h:175: Returning from '__uniq_ptr_impl::_M_ptr'
__uniq_ptr_impl(pointer __p) : _M_t() { _M_ptr() = __p; }
^/usr/include/c++/13/bits/unique_ptr.h:175: The value of '__p' is assigned to 'content._M_t._M_t._M_head_impl'
__uniq_ptr_impl(pointer __p) : _M_t() { _M_ptr() = __p; }
^/usr/include/c++/13/bits/unique_ptr.h:603: Returning from constructor for '__uniq_ptr_impl<char, std::default_delete<char[]>>'
: _M_t(__p)
^/usr/include/c++/13/bits/unique_ptr.h:603: Returning from constructor for '__uniq_ptr_data<char, std::default_delete<char[]>, true, true>'
: _M_t(__p)
^lib/CppInterOp/CppInterOp.cpp:3925: Returning from constructor for 'unique_ptr<char[], std::default_delete<char[]>>'
std::unique_ptr<char[]> content(new char[bufsize + 1]);
^lib/CppInterOp/CppInterOp.cpp:3928: Taking false branch
if (fseek(m_TempFile, 0L, SEEK_SET) != 0)
^lib/CppInterOp/CppInterOp.cpp:3932: The 1st argument to 'fread' is a buffer with size 0 but should be a buffer with size equal to or greater than the value of the 2nd argument (which is 1) times the 3rd argument (which is 18446744073709551615)
size_t newLen = fread(content.get(), sizeof(char), bufsize, m_TempFile);
^| getOutOfProcess() = false; | ||
| #else | ||
| getOutOfProcess() = | ||
| std::any_of(vargs.begin(), vargs.end(), [](const char* arg) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "std::any_of" is directly included [misc-include-cleaner]
lib/CppInterOp/CppInterOpInterpreter.h:25:
- #if CLANG_VERSION_MAJOR >= 19
+ #include <algorithm>
+ #if CLANG_VERSION_MAJOR >= 19| "with in-process JIT execution.\n"; | ||
| getOutOfProcess() = false; | ||
| } else { | ||
| stdin_fd = fileno(getStdinFile().get()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "fileno" is directly included [misc-include-cleaner]
lib/CppInterOp/CppInterOpInterpreter.h:25:
- #if CLANG_VERSION_MAJOR >= 19
+ #include <stdio.h>
+ #if CLANG_VERSION_MAJOR >= 19There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
| size_t newLen = | ||
| fread(content.get(), sizeof(char), bufsize, m_TempFile.get()); | ||
| if (ferror(m_TempFile.get()) != 0) | ||
| size_t newLen = fread(content.get(), sizeof(char), bufsize, m_TempFile); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: The 1st argument to 'fread' is a buffer with size 0 but should be a buffer with size equal to or greater than the value of the 2nd argument (which is 1) times the 3rd argument (which is 18446744073709551615) [clang-analyzer-unix.StdCLibraryFunctions]
size_t newLen = fread(content.get(), sizeof(char), bufsize, m_TempFile);
^Additional context
lib/CppInterOp/CppInterOp.cpp:3968: Calling 'StreamCaptureInfo::GetCapturedString'
std::string result = SCI.GetCapturedString();
^lib/CppInterOp/CppInterOp.cpp:3916: Taking false branch
if (dup2(m_DupFD, m_FD) < 0)
^lib/CppInterOp/CppInterOp.cpp:3919: Taking false branch
if (fseek(m_TempFile, 0L, SEEK_END) != 0)
^lib/CppInterOp/CppInterOp.cpp:3923: Assuming that 'ftell' fails
long bufsize = ftell(m_TempFile);
^lib/CppInterOp/CppInterOp.cpp:3923: 'bufsize' initialized here
long bufsize = ftell(m_TempFile);
^lib/CppInterOp/CppInterOp.cpp:3924: Taking true branch
if (bufsize == -1)
^lib/CppInterOp/CppInterOp.cpp:3928: Storing uninitialized value
std::unique_ptr<char[]> content(new char[bufsize + 1]);
^lib/CppInterOp/CppInterOp.cpp:3928: Passing value via 1st parameter '__p'
std::unique_ptr<char[]> content(new char[bufsize + 1]);
^lib/CppInterOp/CppInterOp.cpp:3928: Calling constructor for 'unique_ptr<char[], std::default_delete<char[]>>'
std::unique_ptr<char[]> content(new char[bufsize + 1]);
^/usr/include/c++/13/bits/unique_ptr.h:603: Calling constructor for '__uniq_ptr_data<char, std::default_delete<char[]>, true, true>'
: _M_t(__p)
^/usr/include/c++/13/bits/unique_ptr.h:603: Passing '' via 1st parameter '__p'
: _M_t(__p)
^/usr/include/c++/13/bits/unique_ptr.h:603: Calling constructor for '__uniq_ptr_impl<char, std::default_delete<char[]>>'
: _M_t(__p)
^/usr/include/c++/13/bits/unique_ptr.h:175: Calling '__uniq_ptr_impl::_M_ptr'
__uniq_ptr_impl(pointer __p) : _M_t() { _M_ptr() = __p; }
^/usr/include/c++/13/bits/unique_ptr.h:196: Calling 'get<0UL, char *, std::default_delete<char[]>>'
pointer& _M_ptr() noexcept { return std::get<0>(_M_t); }
^/usr/include/c++/13/tuple:1803: Calling '__get_helper<0UL, char *, std::default_delete<char[]>>'
{ return std::__get_helper<__i>(__t); }
^/usr/include/c++/13/tuple:1787: Calling '_Tuple_impl::_M_head'
{ return _Tuple_impl<__i, _Head, _Tail...>::_M_head(__t); }
^/usr/include/c++/13/tuple:268: Calling '_Head_base::_M_head'
_M_head(_Tuple_impl& __t) noexcept { return _Base::_M_head(__t); }
^/usr/include/c++/13/tuple:268: Returning from '_Head_base::_M_head'
_M_head(_Tuple_impl& __t) noexcept { return _Base::_M_head(__t); }
^/usr/include/c++/13/tuple:1787: Returning from '_Tuple_impl::_M_head'
{ return _Tuple_impl<__i, _Head, _Tail...>::_M_head(__t); }
^/usr/include/c++/13/tuple:1803: Returning from '__get_helper<0UL, char *, std::default_delete<char[]>>'
{ return std::__get_helper<__i>(__t); }
^/usr/include/c++/13/bits/unique_ptr.h:196: Returning from 'get<0UL, char *, std::default_delete<char[]>>'
pointer& _M_ptr() noexcept { return std::get<0>(_M_t); }
^/usr/include/c++/13/bits/unique_ptr.h:175: Returning from '__uniq_ptr_impl::_M_ptr'
__uniq_ptr_impl(pointer __p) : _M_t() { _M_ptr() = __p; }
^/usr/include/c++/13/bits/unique_ptr.h:175: The value of '__p' is assigned to 'content._M_t._M_t._M_head_impl'
__uniq_ptr_impl(pointer __p) : _M_t() { _M_ptr() = __p; }
^/usr/include/c++/13/bits/unique_ptr.h:603: Returning from constructor for '__uniq_ptr_impl<char, std::default_delete<char[]>>'
: _M_t(__p)
^/usr/include/c++/13/bits/unique_ptr.h:603: Returning from constructor for '__uniq_ptr_data<char, std::default_delete<char[]>, true, true>'
: _M_t(__p)
^lib/CppInterOp/CppInterOp.cpp:3928: Returning from constructor for 'unique_ptr<char[], std::default_delete<char[]>>'
std::unique_ptr<char[]> content(new char[bufsize + 1]);
^lib/CppInterOp/CppInterOp.cpp:3931: Taking false branch
if (fseek(m_TempFile, 0L, SEEK_SET) != 0)
^lib/CppInterOp/CppInterOp.cpp:3935: The 1st argument to 'fread' is a buffer with size 0 but should be a buffer with size equal to or greater than the value of the 2nd argument (which is 1) times the 3rd argument (which is 18446744073709551615)
size_t newLen = fread(content.get(), sizeof(char), bufsize, m_TempFile);
^There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
| @@ -1,3 +1,4 @@ | |||
| #include "Utils.h" | |||
| #include "CppInterOp/CppInterOp.h" | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: included header Utils.h is not used directly [misc-include-cleaner]
| #include "CppInterOp/CppInterOp.h" | |
| #include "CppInterOp/CppInterOp.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
| if (compat::Interpreter::isOutOfProcess() && FD == STDOUT_FILENO) { | ||
| m_TempFile = compat::Interpreter::getTempFileForOOP(FD); | ||
| ::fflush(m_TempFile); | ||
| m_FD = fileno(m_TempFile); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "fflush" is directly included [misc-include-cleaner]
::fflush(m_TempFile);
^| m_OwnsFile = false; | ||
| } else { | ||
| m_TempFile = tmpfile(); | ||
| m_FD = FD; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: assigning newly created 'gsl::owner<>' to non-owner 'FILE *' (aka '_IO_FILE *') [cppcoreguidelines-owning-memory]
m_TempFile = tmpfile();
^| m_OwnsFile = false; | ||
| } else { | ||
| m_TempFile = tmpfile(); | ||
| m_FD = FD; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "tmpfile" is directly included [misc-include-cleaner]
m_TempFile = tmpfile();
^| assert(m_DupFD == -1 && "Captured output not used?"); | ||
| if (m_TempFile && m_OwnsFile) { | ||
| fclose(m_TempFile); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: calling legacy resource function without passing a 'gsl::owner<>' [cppcoreguidelines-owning-memory]
fclose(m_TempFile);
^| assert(m_DupFD == -1 && "Captured output not used?"); | ||
| if (m_TempFile && m_OwnsFile) { | ||
| fclose(m_TempFile); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "fclose" is directly included [misc-include-cleaner]
fclose(m_TempFile);
^| fread(content.get(), sizeof(char), bufsize, m_TempFile.get()); | ||
| if (ferror(m_TempFile.get()) != 0) | ||
| size_t newLen = fread(content.get(), sizeof(char), bufsize, m_TempFile); | ||
| if (ferror(m_TempFile) != 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: The 1st argument to 'fread' is a buffer with size 0 but should be a buffer with size equal to or greater than the value of the 2nd argument (which is 1) times the 3rd argument (which is 18446744073709551615) [clang-analyzer-unix.StdCLibraryFunctions]
size_t newLen = fread(content.get(), sizeof(char), bufsize, m_TempFile);
^Additional context
lib/CppInterOp/CppInterOp.cpp:3966: Calling 'StreamCaptureInfo::GetCapturedString'
std::string result = SCI.GetCapturedString();
^lib/CppInterOp/CppInterOp.cpp:3914: Taking false branch
if (dup2(m_DupFD, m_FD) < 0)
^lib/CppInterOp/CppInterOp.cpp:3917: Taking false branch
if (fseek(m_TempFile, 0L, SEEK_END) != 0)
^lib/CppInterOp/CppInterOp.cpp:3921: Assuming that 'ftell' fails
long bufsize = ftell(m_TempFile);
^lib/CppInterOp/CppInterOp.cpp:3921: 'bufsize' initialized here
long bufsize = ftell(m_TempFile);
^lib/CppInterOp/CppInterOp.cpp:3922: Taking true branch
if (bufsize == -1)
^lib/CppInterOp/CppInterOp.cpp:3926: Storing uninitialized value
std::unique_ptr<char[]> content(new char[bufsize + 1]);
^lib/CppInterOp/CppInterOp.cpp:3926: Passing value via 1st parameter '__p'
std::unique_ptr<char[]> content(new char[bufsize + 1]);
^lib/CppInterOp/CppInterOp.cpp:3926: Calling constructor for 'unique_ptr<char[], std::default_delete<char[]>>'
std::unique_ptr<char[]> content(new char[bufsize + 1]);
^/usr/include/c++/13/bits/unique_ptr.h:603: Calling constructor for '__uniq_ptr_data<char, std::default_delete<char[]>, true, true>'
: _M_t(__p)
^/usr/include/c++/13/bits/unique_ptr.h:603: Passing '' via 1st parameter '__p'
: _M_t(__p)
^/usr/include/c++/13/bits/unique_ptr.h:603: Calling constructor for '__uniq_ptr_impl<char, std::default_delete<char[]>>'
: _M_t(__p)
^/usr/include/c++/13/bits/unique_ptr.h:175: Calling '__uniq_ptr_impl::_M_ptr'
__uniq_ptr_impl(pointer __p) : _M_t() { _M_ptr() = __p; }
^/usr/include/c++/13/bits/unique_ptr.h:196: Calling 'get<0UL, char *, std::default_delete<char[]>>'
pointer& _M_ptr() noexcept { return std::get<0>(_M_t); }
^/usr/include/c++/13/tuple:1803: Calling '__get_helper<0UL, char *, std::default_delete<char[]>>'
{ return std::__get_helper<__i>(__t); }
^/usr/include/c++/13/tuple:1787: Calling '_Tuple_impl::_M_head'
{ return _Tuple_impl<__i, _Head, _Tail...>::_M_head(__t); }
^/usr/include/c++/13/tuple:268: Calling '_Head_base::_M_head'
_M_head(_Tuple_impl& __t) noexcept { return _Base::_M_head(__t); }
^/usr/include/c++/13/tuple:268: Returning from '_Head_base::_M_head'
_M_head(_Tuple_impl& __t) noexcept { return _Base::_M_head(__t); }
^/usr/include/c++/13/tuple:1787: Returning from '_Tuple_impl::_M_head'
{ return _Tuple_impl<__i, _Head, _Tail...>::_M_head(__t); }
^/usr/include/c++/13/tuple:1803: Returning from '__get_helper<0UL, char *, std::default_delete<char[]>>'
{ return std::__get_helper<__i>(__t); }
^/usr/include/c++/13/bits/unique_ptr.h:196: Returning from 'get<0UL, char *, std::default_delete<char[]>>'
pointer& _M_ptr() noexcept { return std::get<0>(_M_t); }
^/usr/include/c++/13/bits/unique_ptr.h:175: Returning from '__uniq_ptr_impl::_M_ptr'
__uniq_ptr_impl(pointer __p) : _M_t() { _M_ptr() = __p; }
^/usr/include/c++/13/bits/unique_ptr.h:175: The value of '__p' is assigned to 'content._M_t._M_t._M_head_impl'
__uniq_ptr_impl(pointer __p) : _M_t() { _M_ptr() = __p; }
^/usr/include/c++/13/bits/unique_ptr.h:603: Returning from constructor for '__uniq_ptr_impl<char, std::default_delete<char[]>>'
: _M_t(__p)
^/usr/include/c++/13/bits/unique_ptr.h:603: Returning from constructor for '__uniq_ptr_data<char, std::default_delete<char[]>, true, true>'
: _M_t(__p)
^lib/CppInterOp/CppInterOp.cpp:3926: Returning from constructor for 'unique_ptr<char[], std::default_delete<char[]>>'
std::unique_ptr<char[]> content(new char[bufsize + 1]);
^lib/CppInterOp/CppInterOp.cpp:3929: Taking false branch
if (fseek(m_TempFile, 0L, SEEK_SET) != 0)
^lib/CppInterOp/CppInterOp.cpp:3933: The 1st argument to 'fread' is a buffer with size 0 but should be a buffer with size equal to or greater than the value of the 2nd argument (which is 1) times the 3rd argument (which is 18446744073709551615)
size_t newLen = fread(content.get(), sizeof(char), bufsize, m_TempFile);
^| fread(content.get(), sizeof(char), bufsize, m_TempFile.get()); | ||
| if (ferror(m_TempFile.get()) != 0) | ||
| size_t newLen = fread(content.get(), sizeof(char), bufsize, m_TempFile); | ||
| if (ferror(m_TempFile) != 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "fread" is directly included [misc-include-cleaner]
size_t newLen = fread(content.get(), sizeof(char), bufsize, m_TempFile);
^
Description
Please include a summary of changes, motivation and context for this PR.
Fixes # (issue)
Type of change
Please tick all options which are relevant.
Testing
Please describe the test(s) that you added and ran to verify your changes.
Checklist