PerlFFI / FFI-Platypus

Write Perl bindings to non-Perl libraries with FFI. No XS required.
89 stars 23 forks source link

logs filled with "unable to find ffi_pl_bundle_init" errors #295

Closed rmesser closed 2 years ago

rmesser commented 3 years ago

My company is running FFI::Platypus in a web server, and recently we've been getting lots of lines in our log files like this:

main::__ANON__('unable to find ffi_pl_bundle_init at /home/intellisurvey/isapps/lib/perl5/site_perl/5.22.4/x86_64-linux/FFI/Platypus/Memory.pm line 17.^J') called at /home/intellisurvey/isapps/lib/perl5/site_perl/5.22.4/Carp.pm line 167
Carp::croak('unable to find ffi_pl_bundle_init') called at /home/intellisurvey/isapps/lib/perl5/site_perl/5.22.4/x86_64-linux/FFI/Platypus.pm line 311
FFI::Platypus::function('FFI::Platypus=HASH(0x176e2128)', 'ffi_pl_bundle_init', 'ARRAY(0x176d9830)', 'void') called at /home/intellisurvey/isapps/lib/perl5/site_perl/5.22.4/x86_64-linux/FFI/Platypus/Bundle.pm line 115
eval {...} at /home/intellisurvey/isapps/lib/perl5/site_perl/5.22.4/x86_64-linux/FFI/Platypus/Bundle.pm line 115

It seems that these messages appear on systems with some versions of libffi, but not on others with older versions. I looked into the code lines referenced in the log messages, and it appears the ffi_pl_bundle_init call is wrapped in an eval, apparently because it may or may not be relevant depending on the version of libffi. Is that correct? Before I ignore these warnings I'd like to make sure I understand the cause. Thanks.

plicease commented 3 years ago

It is in an eval because bundled libraries are not required to have that symbol. The function is only called when it is found. In this case it is calling the bundle that came with FFI::Platypus which was introduced around about version 1.00 and does not use that entrypoint. It shouldn't matter which version of libffi that you are using, and it should be silent unless you have a __DIE__ handler or something like that.

If you run this:

perl -MFFI::Platypus::Memory -E 1

do you see the diagnostic?

rmesser commented 3 years ago

No, I don't get the diagnostic when I run the one-liner.

And I don't get it in other cases either, and so I'm trying to investigate why it appears in some cases and not others. We aren't adding a DIE handler ourselves, but we are using Try::Tiny and various other modules so perhaps that has something to do with it.

Also by way of background, the error is triggered by this line in our code:

 my $context = ZMQ::FFI->new();

We've upgraded to the latest version of ZMQ::FFI and FFI::Platypus and other modules, but the warning messages persist. I'll investigate further and if I have a clear way to repro it I'll post again. Or if you have ideas on how to resolve it please advise. Thanks much.

plicease commented 3 years ago

We've upgraded to the latest version of ZMQ::FFI and FFI::Platypus and other modules, but the warning messages persist. I'll investigate further and if I have a clear way to repro it I'll post again. Or if you have ideas on how to resolve it please advise. Thanks much.

I don't have any suggestions atm. Since loading the memory module by itself doesn't generate the diagnostic I believe this is an interaction with another module. If you can isolate that and let me know what you find I may be able to help further.

plicease commented 2 years ago

closing since I am not able to reproduce. Please re-open with comments if you can provide a short example that demonstrates this is a bug in FFI-Platypus.