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

Use default new C++11 ABI for std::string and std::list in libstdc++ #31

Merged
merged 2 commits into from
Dec 3, 2021

Conversation

pcolberg
Copy link
Contributor

@pcolberg pcolberg commented Dec 3, 2021

This flag was once used as a work-around for very old linkers and has
not been needed for a long time. The ABI change does not affect the
public runtime ABI since the runtime does not expose any C++ symbols.
The ABI change does affect the size of OpenCL data structures, however
these are not exposed directly but only in the form of opaque pointers.

https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html

This flag was once used as a work-around for very old linkers and has
not been needed for a long time. The ABI change does not affect the
public runtime ABI since the runtime does not expose any C++ symbols.
The ABI change does affect the size of OpenCL data structures, however
these are not exposed directly but only in the form of opaque pointers.

https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html
@pcolberg pcolberg added this to the 2022.2 milestone Dec 3, 2021
@pcolberg pcolberg self-assigned this Dec 3, 2021
@pcolberg pcolberg requested a review from zibaiwan December 3, 2021 00:31
@pcolberg pcolberg marked this pull request as draft December 3, 2021 00:37
zibaiwan
zibaiwan previously approved these changes Dec 3, 2021
Copy link
Contributor

@zibaiwan zibaiwan left a comment

Choose a reason for hiding this comment

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

Looks good! Thanks @pcolberg .

@pcolberg pcolberg force-pushed the use-cxx11-abi branch 2 times, most recently from 0066c42 to b69dd25 Compare December 3, 2021 03:10
After switching libstdc++ from the old to the default, new C++11 ABI,
Klocwork static analysis flags that assignment to std::string with a
string literal may result in a non null terminated string. While it is
not apparent whether this is a false-positive or not, initializing the
string with the literal by default resolves the Klocwork issue.

---------------------------------------------------------------------------
182 (Local) /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/src/acl_hal_mmd.cpp:782 NNTS.MUST (1:Critical) Analyze
Buffer overflow of 'board_vendor_path._M_dataplus._M_p' due to non null terminated string 'board_vendor_path._M_dataplus._M_p'
  * acl_hal_mmd.cpp:773: customer_board_vendor_path is false
  * acl_hal_mmd.cpp:779: 'board_vendor_path._M_dataplus._M_p' may not be null-terminated after calling 'operator='.
    * basic_string.h:705: 'this->_M_dataplus._M_p' may not be null-terminated after calling 'assign'.
      * basic_string.h:1438: 'this->_M_dataplus._M_p' may not be null-terminated after calling '_M_replace'.
        * basic_string.tcc:429: __new_size<=this->capacity() is false
        * basic_string.tcc:465: 'this->_M_dataplus._M_p' may not be null-terminated after calling '_M_mutate'.
          * basic_string.tcc:318: __pos is true
          * basic_string.tcc:319: '__r' may not be null-terminated after calling '_S_copy'.
            * basic_string.h:348: __n==1 is false
            * basic_string.h:351: '__d' may not be null-terminated after calling 'copy'.
              * char_traits.h:365: The size parameter may be less than length of source buffer.
              * char_traits.h:365: '__s1' may not be null-terminated after calling '__builtin_memcpy'.
          * basic_string.tcc:320: __len2 is false
          * basic_string.tcc:320: __s&&__len2 is false
          * basic_string.tcc:322: __how_much is false
          * basic_string.tcc:327: _M_data(__r): copies '__r' into 'this->_M_dataplus._M_p'
  * acl_hal_mmd.cpp:783: board_vendor_path.c_str(): returns 'board_vendor_path._M_dataplus._M_p'
  * acl_hal_mmd.cpp:782: String 'board_vendor_path._M_dataplus._M_p' is not properly terminated and is passed as an argument to function 'printf'.
Current status 'Analyze'

---------------------------------------------------------------------------
183 (Local) /__w/fpga-runtime-for-opencl/fpga-runtime-for-opencl/src/acl_hal_mmd.cpp:798 NNTS.MUST (1:Critical) Analyze
Buffer overflow of 'board_vendor_path._M_dataplus._M_p' due to non null terminated string 'board_vendor_path._M_dataplus._M_p'
  * acl_hal_mmd.cpp:773: customer_board_vendor_path is false
  * acl_hal_mmd.cpp:779: 'board_vendor_path._M_dataplus._M_p' may not be null-terminated after calling 'operator='.
    * basic_string.h:705: 'this->_M_dataplus._M_p' may not be null-terminated after calling 'assign'.
      * basic_string.h:1438: 'this->_M_dataplus._M_p' may not be null-terminated after calling '_M_replace'.
        * basic_string.tcc:429: __new_size<=this->capacity() is false
        * basic_string.tcc:465: 'this->_M_dataplus._M_p' may not be null-terminated after calling '_M_mutate'.
          * basic_string.tcc:318: __pos is true
          * basic_string.tcc:319: '__r' may not be null-terminated after calling '_S_copy'.
            * basic_string.h:348: __n==1 is false
            * basic_string.h:351: '__d' may not be null-terminated after calling 'copy'.
              * char_traits.h:365: The size parameter may be less than length of source buffer.
              * char_traits.h:365: '__s1' may not be null-terminated after calling '__builtin_memcpy'.
          * basic_string.tcc:320: __len2 is false
          * basic_string.tcc:320: __s&&__len2 is false
          * basic_string.tcc:322: __how_much is false
          * basic_string.tcc:327: _M_data(__r): copies '__r' into 'this->_M_dataplus._M_p'
  * acl_hal_mmd.cpp:782: debug_verbosity>=1 is false
  * acl_hal_mmd.cpp:821: debug_verbosity>=1 is false
  * acl_hal_mmd.cpp:798: board_vendor_path.c_str(): returns 'board_vendor_path._M_dataplus._M_p'
  * acl_hal_mmd.cpp:798: String 'board_vendor_path._M_dataplus._M_p' is not properly terminated and is passed as an argument to function 'opendir'.
Current status 'Analyze'
@pcolberg
Copy link
Contributor Author

pcolberg commented Dec 3, 2021

Thanks @zibaiwan. I have updated the commit message of the Klocwork fix after the test proved successful.

@pcolberg pcolberg marked this pull request as ready for review December 3, 2021 03:17
@pcolberg pcolberg merged commit e0c5dc2 into intel:main Dec 3, 2021
@pcolberg pcolberg deleted the use-cxx11-abi branch December 3, 2021 14:50
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.

2 participants