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

Ruby 3.2 warning: undefining the allocator of T_DATA class TinyTds::Result #515

Closed
jeremyevans opened this issue Apr 12, 2022 · 1 comment · Fixed by #542
Closed

Ruby 3.2 warning: undefining the allocator of T_DATA class TinyTds::Result #515

jeremyevans opened this issue Apr 12, 2022 · 1 comment · Fixed by #542

Comments

@jeremyevans
Copy link
Contributor

When running tiny_tds on Ruby 3.2.0-preview 1, you get a warning when first accessing the TinyTds::Result class:

warning: undefining the allocator of T_DATA class TinyTds::Result

You can probably avoid this by adding rb_undef_alloc_func(cTinyTdsResult); after

cTinyTdsResult = rb_define_class_under(mTinyTds, "Result", rb_cObject);

For details, see https://bugs.ruby-lang.org/issues/18007 and https://ruby-doc.org/core-3.1.1/doc/extension_rdoc.html#label-C+struct+to+Ruby+object

@stillhart
Copy link

Wow, @jeremyevans, you were early :-). I get this warning now with the official release of Ruby 3.2.0, so it's still relevant.

stoivo added a commit to stoivo/ruby-filemagic that referenced this issue Apr 25, 2023
* Undefine allocation function for C extension class

Since Ruby 3.2 a new warning is printed when a Ruby class created in a C
extension does not specify an allocate function or undefine it.

```
/gem/lib/appsignal/transaction.rb:98: warning: undefining the allocator of T_DATA class Appsignal::Extension::Transaction
/gem/lib/appsignal/utils/data.rb:19: warning: undefining the allocator of T_DATA class Appsignal::Extension::Data
```

From my understanding, we only need to define an allocate function if
the class uses a C struct and stores any values on it. Our classes don't
do that in C, that's done in our Rust extension.

Closes #909

## Resources

https://bugs.ruby-lang.org/issues/18007
https://github.com/ruby/ruby/blob/6963f8f743b42f9004a0879cd66c550f18987352/doc/extension.rdoc#label-Write+the+C+Code
https://ruby-doc.org/core-3.1.1/doc/extension_rdoc.html#label-C+struct+to+Ruby+object

rails-sqlserver/tiny_tds#515
https://groups.google.com/g/sequel-talk/c/K0J80s4wGJU/m/BT-6FFhrAgAJ

## Other MR doing similar change
vmg/redcarpet#721
appsignal/appsignal-ruby#917
stoivo added a commit to stoivo/ruby-filemagic that referenced this issue Apr 25, 2023
* Undefine allocation function for C extension class

Since Ruby 3.2 a new warning is printed when a Ruby class created in a C
extension does not specify an allocate function or undefine it.

```
/gem/lib/appsignal/transaction.rb:98: warning: undefining the allocator of T_DATA class Appsignal::Extension::Transaction
/gem/lib/appsignal/utils/data.rb:19: warning: undefining the allocator of T_DATA class Appsignal::Extension::Data
```

From my understanding, we only need to define an allocate function if
the class uses a C struct and stores any values on it. Our classes don't
do that in C, that's done in our Rust extension.

Closes #909

## Resources

https://bugs.ruby-lang.org/issues/18007
https://github.com/ruby/ruby/blob/6963f8f743b42f9004a0879cd66c550f18987352/doc/extension.rdoc#label-Write+the+C+Code
https://ruby-doc.org/core-3.1.1/doc/extension_rdoc.html#label-C+struct+to+Ruby+object

rails-sqlserver/tiny_tds#515
https://groups.google.com/g/sequel-talk/c/K0J80s4wGJU/m/BT-6FFhrAgAJ

## Other MR doing similar change
vmg/redcarpet#721
appsignal/appsignal-ruby#917
joast pushed a commit to joast/ruby-filemagic that referenced this issue Dec 7, 2023
* Undefine allocation function for C extension class

Since Ruby 3.2 a new warning is printed when a Ruby class created in a C
extension does not specify an allocate function or undefine it.

```
/gem/lib/appsignal/transaction.rb:98: warning: undefining the allocator of T_DATA class Appsignal::Extension::Transaction
/gem/lib/appsignal/utils/data.rb:19: warning: undefining the allocator of T_DATA class Appsignal::Extension::Data
```

From my understanding, we only need to define an allocate function if
the class uses a C struct and stores any values on it. Our classes don't
do that in C, that's done in our Rust extension.

Closes #909

## Resources

https://bugs.ruby-lang.org/issues/18007
https://github.com/ruby/ruby/blob/6963f8f743b42f9004a0879cd66c550f18987352/doc/extension.rdoc#label-Write+the+C+Code
https://ruby-doc.org/core-3.1.1/doc/extension_rdoc.html#label-C+struct+to+Ruby+object

rails-sqlserver/tiny_tds#515
https://groups.google.com/g/sequel-talk/c/K0J80s4wGJU/m/BT-6FFhrAgAJ

## Other MR doing similar change
vmg/redcarpet#721
appsignal/appsignal-ruby#917
joast pushed a commit to joast/ruby-filemagic that referenced this issue Dec 8, 2023
* Undefine allocation function for C extension class

Since Ruby 3.2 a new warning is printed when a Ruby class created in a C
extension does not specify an allocate function or undefine it.

```
/gem/lib/appsignal/transaction.rb:98: warning: undefining the allocator of T_DATA class Appsignal::Extension::Transaction
/gem/lib/appsignal/utils/data.rb:19: warning: undefining the allocator of T_DATA class Appsignal::Extension::Data
```

From my understanding, we only need to define an allocate function if
the class uses a C struct and stores any values on it. Our classes don't
do that in C, that's done in our Rust extension.

Closes #909

## Resources

https://bugs.ruby-lang.org/issues/18007
https://github.com/ruby/ruby/blob/6963f8f743b42f9004a0879cd66c550f18987352/doc/extension.rdoc#label-Write+the+C+Code
https://ruby-doc.org/core-3.1.1/doc/extension_rdoc.html#label-C+struct+to+Ruby+object

rails-sqlserver/tiny_tds#515
https://groups.google.com/g/sequel-talk/c/K0J80s4wGJU/m/BT-6FFhrAgAJ

## Other MR doing similar change
vmg/redcarpet#721
appsignal/appsignal-ruby#917
stoivo added a commit to stoivo/ruby-filemagic that referenced this issue Jan 29, 2024
* Undefine allocation function for C extension class

Since Ruby 3.2 a new warning is printed when a Ruby class created in a C
extension does not specify an allocate function or undefine it.

```
/gem/lib/appsignal/transaction.rb:98: warning: undefining the allocator of T_DATA class Appsignal::Extension::Transaction
/gem/lib/appsignal/utils/data.rb:19: warning: undefining the allocator of T_DATA class Appsignal::Extension::Data
```

From my understanding, we only need to define an allocate function if
the class uses a C struct and stores any values on it. Our classes don't
do that in C, that's done in our Rust extension.

Closes #909

## Resources

https://bugs.ruby-lang.org/issues/18007
https://github.com/ruby/ruby/blob/6963f8f743b42f9004a0879cd66c550f18987352/doc/extension.rdoc#label-Write+the+C+Code
https://ruby-doc.org/core-3.1.1/doc/extension_rdoc.html#label-C+struct+to+Ruby+object

rails-sqlserver/tiny_tds#515
https://groups.google.com/g/sequel-talk/c/K0J80s4wGJU/m/BT-6FFhrAgAJ

## Other MR doing similar change
vmg/redcarpet#721
appsignal/appsignal-ruby#917
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

Successfully merging a pull request may close this issue.

2 participants