chef / ffi-yajl

Ruby FFI gem wrapper around yajl2 library
MIT License
11 stars 21 forks source link

warning: undefining the allocator of T_DATA class FFI_Yajl::Ext::Encoder::YajlGen #123

Open conathan opened 6 months ago

conathan commented 6 months ago

Version 2.6.0

AlmaLinux 8/9, Ruby 3.2.3 installed via RVM

When we upgraded from using cinc-client 18.3.0 from Ruby 3.1.4 to Ruby 3.2.3, we started getting the following warning:

/usr/lib/rvm/gems/ruby-3.2.3@cinc/gems/ffi-yajl-2.6.0/lib/ffi_yajl/encoder.rb:42: warning: undefining the allocator of T_DATA class FFI_Yajl::Ext::Encoder::YajlGen

I suspect it has to do with https://bugs.ruby-lang.org/issues/18007, added to Ruby 3.2 branch.

conathan commented 1 month ago

Believe this would resolve it

diff -Naurp ffi-yajl-2.6.0.orig/ext/ffi_yajl/ext/encoder/encoder.c ffi-yajl-2.6.0/ext/ffi_yajl/ext/encoder/encoder.c
--- ffi-yajl-2.6.0.orig/ext/ffi_yajl/ext/encoder/encoder.c      2023-07-19 11:39:18.000000000 -0700
+++ ffi-yajl-2.6.0/ext/ffi_yajl/ext/encoder/encoder.c   2024-08-03 18:25:08.174714852 -0700
@@ -360,6 +360,9 @@ void Init_encoder() {
   mExt = rb_define_module_under(mFFI_Yajl, "Ext");
   mEncoder = rb_define_module_under(mExt, "Encoder");
   cYajl_Gen = rb_define_class_under(mEncoder, "YajlGen", rb_cObject);
+  // BN Begin - Fixes undefining the allocator of T_DATA class FFI_Yajl::Ext::Encoder::YajlGen
+  rb_undef_alloc_func(cYajl_Gen);
+  // BN End - Fixes undefining the allocator of T_DATA class FFI_Yajl::Ext::Encoder::YajlGen
   rb_define_method(mEncoder, "do_yajl_encode", mEncoder_do_yajl_encode, 3);

   /* use rb_const_get instead of rb_define_class so that we don't get superclass mismatches */