Hi Dima,

I have been maintaining the Eigen library in Debian for over 12 years,
and I cannot recall the specific bug ticket related to this topic. However,
it seems that the question you have raised is indeed valid. If patching
Eigen in those two places would help resolve the issue, please prepare
a patch, and I believe we can proceed with pushing it.

Does it make sense to discuss this with the Eigen developers? Or is the
question very specific to Debian (or packaging) and might not be of interest
to them?

Best regards,


Anton


Am Mi., 12. Juli 2023 um 01:24 Uhr schrieb Dima Kogan <dko...@debian.org>:

> Hi.
>
> Apologies for taking so long to look at this again; I've been busy.
>
> I just looked into it, and my conclusion is that there's no way to
> ensure that Eigen won't crash without us patching our package. So we
> should patch our package.
>
> I'm attaching a tiny demo program. Extract it and
>
>   make && ./main
>
> You'll see that it crashes. We have lib.cc:
>
>   #include <Eigen/Core>
>
>   __attribute__((visibility("default")))
>   Eigen::MatrixXd* make_array()
>   {
>       return new Eigen::MatrixXd(10,20);
>   }
>
> This is an analogue of some library we would be packaging for Debian.
> This would be built with no cpu-specific options, which is what the
> Makefile in this demo does.
>
> We also have a main.cc:
>
>   #include <Eigen/Core>
>
>   Eigen::MatrixXd* make_array();
>   int main(void)
>   {
>       Eigen::MatrixXd* matrix = make_array();
>       delete matrix;
>       return 0;
>   }
>
> This is an analogue of some user program that uses this library. This
> isn't going into Debian, and the user wants to use their CPU fully, so
> they build with -mavx. This causes Eigen to crash. Because the
> allocation and deallocation paths don't work the same.
>
> In this demo no Eigen symbols are exported from lib.so, so it's not a
> case of the linker picking the wrong weak symbol, and this cannot be
> fixed by symbol versioning or visibility settings or anything.
>
> This isn't a contrived example. I hit this in the real-world with a
> package I'm going to upload soon (g2o).
>
> Can anybody see ways to make Eigen work reliably here without patching
> away the different paths in aligned_malloc() and aligned_free() ?
>
>
> https://sources.debian.org/src/eigen3/3.4.0-4/Eigen/src/Core/util/Memory.h/#L179
>
> https://sources.debian.org/src/eigen3/3.4.0-4/Eigen/src/Core/util/Memory.h/#L200
>
> I don't see any way to do it currently, and probably we should patch
> these out.
>
> There was also a second similar problem I saw earlier, that resulted in
> crashes due to inconsistent alignment. I'm going to revisit that
> shortly.
>
> Thanks.
>
>

Reply via email to