* [PATCH] ruby: fix "undefining the allocator of T_DATA" warnings
@ 2024-09-01 0:02 Johannes Larsen
0 siblings, 0 replies; only message in thread
From: Johannes Larsen @ 2024-09-01 0:02 UTC (permalink / raw)
To: notmuch; +Cc: Johannes Larsen
Ruby 3.2 introduced a warning when C-extensions use structs without
redefining the allocation default allocation routine meant for objects.
See https://bugs.ruby-lang.org/issues/18007 for details.
In the Ruby bindings this happens at `Data_Wrap_Notmuch_Object` call
sites, so the object types used there needed to update their allocation.
This ruby code (given a database at the hardcoded path with messages
matching `tag:tmp`) exercise all the ruby objects:
require 'notmuch'
Notmuch::Database.open File.expand_path("~/mail") do |db|
db.get_directory("/tmp")
db.query("tag:tmp").search_threads.each do |t|
t.messages.each do |m|
puts m.header("Subject")
end
end
end
Before these changes with ruby 3.2.5 and notmuch 0.38.3 it outputs:
notmuch.rb:5: warning: undefining the allocator of T_DATA class Notmuch::Query
notmuch.rb:5: warning: undefining the allocator of T_DATA class Notmuch::Threads
notmuch.rb:5: warning: undefining the allocator of T_DATA class Notmuch::Thread
notmuch.rb:6: warning: undefining the allocator of T_DATA class Notmuch::Messages
notmuch.rb:6: warning: undefining the allocator of T_DATA class Notmuch::Message
notmuch release 0.38.3 now available
(the last line is the message I tagged with tmp), and after the changes:
notmuch release 0.38.3 now available
---
bindings/ruby/init.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/bindings/ruby/init.c b/bindings/ruby/init.c
index 2d1994af..10558a33 100644
--- a/bindings/ruby/init.c
+++ b/bindings/ruby/init.c
@@ -294,4 +294,5 @@ Init_notmuch (void)
*/
notmuch_rb_cQuery = rb_define_class_under (mod, "Query", rb_cObject);
+ rb_undef_alloc_func(notmuch_rb_cQuery);
rb_undef_method (notmuch_rb_cQuery, "initialize");
rb_define_method (notmuch_rb_cQuery, "destroy!", notmuch_rb_query_destroy, 0); /* in query.c */
@@ -312,4 +313,5 @@ Init_notmuch (void)
*/
notmuch_rb_cThreads = rb_define_class_under (mod, "Threads", rb_cObject);
+ rb_undef_alloc_func(notmuch_rb_cThreads);
rb_undef_method (notmuch_rb_cThreads, "initialize");
rb_define_method (notmuch_rb_cThreads, "destroy!", notmuch_rb_threads_destroy, 0); /* in threads.c */
@@ -323,4 +325,5 @@ Init_notmuch (void)
*/
notmuch_rb_cMessages = rb_define_class_under (mod, "Messages", rb_cObject);
+ rb_undef_alloc_func(notmuch_rb_cMessages);
rb_undef_method (notmuch_rb_cMessages, "initialize");
rb_define_method (notmuch_rb_cMessages, "destroy!", notmuch_rb_messages_destroy, 0); /* in messages.c */
@@ -335,4 +338,5 @@ Init_notmuch (void)
*/
notmuch_rb_cThread = rb_define_class_under (mod, "Thread", rb_cObject);
+ rb_undef_alloc_func(notmuch_rb_cThread);
rb_undef_method (notmuch_rb_cThread, "initialize");
rb_define_method (notmuch_rb_cThread, "destroy!", notmuch_rb_thread_destroy, 0); /* in thread.c */
@@ -354,4 +358,5 @@ Init_notmuch (void)
*/
notmuch_rb_cMessage = rb_define_class_under (mod, "Message", rb_cObject);
+ rb_undef_alloc_func(notmuch_rb_cMessage);
rb_undef_method (notmuch_rb_cMessage, "initialize");
rb_define_method (notmuch_rb_cMessage, "destroy!", notmuch_rb_message_destroy, 0); /* in message.c */
--
2.46.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2024-09-01 0:07 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-01 0:02 [PATCH] ruby: fix "undefining the allocator of T_DATA" warnings Johannes Larsen
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).