Skip to content
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

Fixed gcc linker error 58 #4477

Merged
merged 1 commit into from
Feb 28, 2024

Conversation

tmiguelf
Copy link
Contributor

@tmiguelf tmiguelf commented Feb 23, 2024

Fixed gcc linker error 58:

How to reproduce:
Step1. Build the library with a test project deployed on gcc 12.3 on Ubuntu
Step2. Look at the following linker error:

lto-wrapper : warning : using serial compilation of 8 LTRANS jobs
lto-wrapper : message : see the ‘-flto’ option documentation for more information
lto-wrapper : message : In function ‘make_unique’,
E: from ‘CreateArgvFromArgs’ at \mnt\d\Code\utilities\submodules\googletest\googletest\src\gtest-death-test.cc(635): error : 58,
E: from ‘AssumeRole’ at \mnt\d\Code\utilities\submodules\googletest\googletest\src\gtest-death-test.cc(1391): error : 58:
/usr/include/c++/12/bits/unique_ptr.h(1080): error : 30: warning: argument 1 value ‘18446744073709551615’ exceeds maximum object size 9223372036854775807 [-Walloc-size-larger-than=]
/usr/include/c++/12/bits/unique_ptr.h(1080): error :  1080 |     { return unique_ptr<_Tp>(new remove_extent_t<_Tp>[__num]()); }
/usr/include/c++/12/bits/unique_ptr.h(1080): error :       |                              ^
/usr/include/c++/12/new : error : In member function ‘AssumeRole’:
/usr/include/c++/12/new(128): error : 26: note: in a call to allocation function ‘operator new []’ declared here
128 | _GLIBCXX_NODISCARD void* operator new[](std : error : size_t) _GLIBCXX_THROW (std::bad_alloc)
128 | _GLIBCXX_NODISCARD void* operator new[](std : error :       |                          ^

This is traced back line 365: https://github.com/google/googletest/pull/4477/files#diff-97f768d897442b94f24002f6bcff7124e3c73d05b3916fb492ee29436ce0701fL635
specifically the args.size() + 1
where the code analysis tool sees the potential issue of overflowing the storage limits when expanding std::unique_ptr<[]>.
This is easily fixable by abandoning the awkward std::unique_ptr<[]>, since it can be better represented by an std::vector.

granted, likely a bug in the gcc code generation, but it has been there for at least 6 months, someone should have noticed by now. std::unique_ptr<[]> is not great, should have used a std::vector anyways.

Copy link
Member

@derekmauro derekmauro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed gcc linker error 58

I don't know what "Fixed gcc linker error 58" means. Please explain what this error is, how to reproduce it, and how this fixes the problem.

@derekmauro derekmauro self-assigned this Feb 26, 2024
@tmiguelf
Copy link
Contributor Author

tmiguelf commented Feb 26, 2024

Step1. Build the library with a test project deployed on gcc 12.3 on Ubuntu
Step2. Look at the following linker error:

lto-wrapper : warning : using serial compilation of 8 LTRANS jobs
lto-wrapper : message : see the ‘-flto’ option documentation for more information
lto-wrapper : message : In function ‘make_unique’,
E: from ‘CreateArgvFromArgs’ at \mnt\d\Code\utilities\submodules\googletest\googletest\src\gtest-death-test.cc(635): error : 58,
E: from ‘AssumeRole’ at \mnt\d\Code\utilities\submodules\googletest\googletest\src\gtest-death-test.cc(1391): error : 58:
/usr/include/c++/12/bits/unique_ptr.h(1080): error : 30: warning: argument 1 value ‘18446744073709551615’ exceeds maximum object size 9223372036854775807 [-Walloc-size-larger-than=]
/usr/include/c++/12/bits/unique_ptr.h(1080): error :  1080 |     { return unique_ptr<_Tp>(new remove_extent_t<_Tp>[__num]()); }
/usr/include/c++/12/bits/unique_ptr.h(1080): error :       |                              ^
/usr/include/c++/12/new : error : In member function ‘AssumeRole’:
/usr/include/c++/12/new(128): error : 26: note: in a call to allocation function ‘operator new []’ declared here
128 | _GLIBCXX_NODISCARD void* operator new[](std : error : size_t) _GLIBCXX_THROW (std::bad_alloc)
128 | _GLIBCXX_NODISCARD void* operator new[](std : error :       |                          ^

This is traced back line 365: https://github.com/google/googletest/pull/4477/files#diff-97f768d897442b94f24002f6bcff7124e3c73d05b3916fb492ee29436ce0701fL635
specifically the args.size() + 1
where the code analysis tool sees the potential issue of overflowing the storage limits when expanding std::unique_ptr<[]>.
This is easily fixable by abandoning the awkward std::unique_ptr<[]>, since it can be better represented by an std::vector.

granted, likely a bug in the gcc code generation, but it has been there for at least 6 months, someone should have noticed by now. std::unique_ptr<[]> is not great, should have used a std::vector anyways.

@copybara-service copybara-service bot merged commit e15c5a5 into google:main Feb 28, 2024
1 check passed
@tmiguelf tmiguelf deleted the feature/soup_cleanup branch February 28, 2024 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants