facebookexperimental / object-introspection

Object Introspection (OI) enables on-demand, hierarchical profiling of objects in arbitrary C/C++ programs with no recompilation.
Apache License 2.0
160 stars 13 forks source link

fix string type sso computation #469

Closed qbojj closed 7 months ago

qbojj commented 7 months ago

Summary

The sso flag in string types was calculated wrongly:

containter.data() >= &container && containter.data() < (&container + sizeof(container))

But because the &container is of type std::basic_string<>* the + already multiplies by sizeof.

Note:

Some other types had similar problem, so I have changed them too.

facebook-github-bot commented 7 months ago

Hi @qbojj!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

codecov-commenter commented 7 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (b5b94ed) 62.51% compared to head (8e265f3) 62.50%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #469 +/- ## ========================================== - Coverage 62.51% 62.50% -0.01% ========================================== Files 123 123 Lines 12072 12072 Branches 1966 1966 ========================================== - Hits 7547 7546 -1 - Misses 3570 3571 +1 Partials 955 955 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

JakeHillion commented 7 months ago

This is great, thanks for taking the time to fix this! Would you consider instead fixing the isStorageInline helper in OITraceCode.cpp and updating these containers to use that check? This would help others avoid this mistake in the future.

facebook-github-bot commented 7 months ago

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

qbojj commented 7 months ago

I was thinking about making a helper, but (as I don't know the structure of this project) I wasn't sure where to put it. Well as it turns out there was already a helper but no one was using it.

BTW this exact problem could be seen in the presentation during CppCon (YouTube).