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

[Bug]: FixedArray triggers -Wfree-nonheap-object warnings in LTO builds #1843

Open
sergiud opened this issue Feb 20, 2025 · 3 comments
Open

Comments

@sergiud
Copy link

sergiud commented Feb 20, 2025

Describe the issue

Using GCC 14.2.1 we see the following warnings:

/usr/include/eigen3/Eigen/src/Core/ProductEvaluators.h:29: note: a type with different bases is defined in another translation unit
   29 | struct evaluator<Product<Lhs, Rhs, Options> >
[788/969] Linking CXX executable bin/numeric_diff_cost_function_test
In member function ‘deallocate’,
    inlined from ‘deallocate’ at /usr/include/c++/14.2.1/bits/alloc_traits.h:513:23,
    inlined from ‘__dt_base ’ at /home/sergiu/Projects/ceres-solver/third_party/abseil-cpp/absl/container/fixed_array.h:481:36,
    inlined from ‘__dt_base ’ at /home/sergiu/Projects/ceres-solver/third_party/abseil-cpp/absl/container/fixed_array.h:174:3,
    inlined from ‘EvaluateJacobianForParameterBlock’ at /home/sergiu/Projects/ceres-solver/include/ceres/internal/numeric_diff.h:170:3,
    inlined from ‘Apply’ at /home/sergiu/Projects/ceres-solver/include/ceres/internal/numeric_diff.h:462:52,
    inlined from ‘Evaluate’ at /home/sergiu/Projects/ceres-solver/include/ceres/numeric_diff_cost_function.h:262:47:
/usr/include/c++/14.2.1/bits/new_allocator.h:172:33: warning: ‘operator delete’ called on unallocated object ‘residual_array’ [-Wfree-nonheap-object]
  172 |         _GLIBCXX_OPERATOR_DELETE(_GLIBCXX_SIZED_DEALLOC(__p, __n));
      |                                 ^
/home/sergiu/Projects/ceres-solver/include/ceres/internal/numeric_diff.h: In member function ‘Evaluate’:
/home/sergiu/Projects/ceres-solver/include/ceres/internal/numeric_diff.h:129:30: note: declared here
  129 |     absl::FixedArray<double> residual_array(num_residuals_internal);
      |                              ^
In member function ‘deallocate’,
    inlined from ‘deallocate’ at /usr/include/c++/14.2.1/bits/alloc_traits.h:513:23,
    inlined from ‘__dt_base ’ at /home/sergiu/Projects/ceres-solver/third_party/abseil-cpp/absl/container/fixed_array.h:481:36,
    inlined from ‘__dt_base ’ at /home/sergiu/Projects/ceres-solver/third_party/abseil-cpp/absl/container/fixed_array.h:174:3,
    inlined from ‘EvaluateJacobianForParameterBlock’ at /home/sergiu/Projects/ceres-solver/include/ceres/internal/numeric_diff.h:170:3,
    inlined from ‘Apply’ at /home/sergiu/Projects/ceres-solver/include/ceres/internal/numeric_diff.h:462:52,
    inlined from ‘Evaluate’ at /home/sergiu/Projects/ceres-solver/include/ceres/numeric_diff_cost_function.h:262:47:
/usr/include/c++/14.2.1/bits/new_allocator.h:172:33: warning: ‘operator delete’ called on unallocated object ‘residual_array’ [-Wfree-nonheap-object]
  172 |         _GLIBCXX_OPERATOR_DELETE(_GLIBCXX_SIZED_DEALLOC(__p, __n));
      |                                 ^
/home/sergiu/Projects/ceres-solver/include/ceres/internal/numeric_diff.h: In member function ‘Evaluate’:
/home/sergiu/Projects/ceres-solver/include/ceres/internal/numeric_diff.h:129:30: note: declared here
  129 |     absl::FixedArray<double> residual_array(num_residuals_internal);
      |   

Steps to reproduce the problem

  1. Construct absl::FixedArray<double> a(n).
  2. Compile using -flto=auto.

What version of Abseil are you using?

The lts_2024_01_16 branch.

What operating system and version are you using?

ArchLinux

What compiler and version are you using?

GCC 14.2.1

What build system are you using?

cmake version 3.31.5

Additional context

No response

@derekmauro
Copy link
Member

There is not enough information in this bug report for me to quickly figure out the problem. Please post a full small reproduction of the problem. absl::FixedArray<double> a(n) is meaningless without the value of n, for example. I need all the code.

@sergiud
Copy link
Author

sergiud commented Feb 20, 2025

absl::FixedArray<double> a(n) is not meaningless since any variation of this line and enabled LTO exactly triggers the warning. The reproducer also does not depend on a specific value of n, hence the placeholder. You can use any value greater 0.

@derekmauro
Copy link
Member

derekmauro commented Feb 21, 2025

bazel test --copt=-flto=auto --linkopt=-flto=auto --test_tag_filters=-benchmark ... does not produce the above warning for me. The reproduction instructions are missing information.

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

No branches or pull requests

2 participants