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

memcached uses lower-case class names #2739

Closed
nirvdrum opened this issue Sep 23, 2022 · 3 comments
Closed

memcached uses lower-case class names #2739

nirvdrum opened this issue Sep 23, 2022 · 3 comments
Assignees
Labels

Comments

@nirvdrum
Copy link
Collaborator

The last released version of memcached (1.8.0, released on 07-May-2014) defines a class with a lower-case name in a native extension. rb_define_class allows this, but TruffleRuby's implementation does not because it shares code with the Ruby side of things and performs name validation. This results in the gem being unable to load:

NameError:
  wrong constant name swig_runtime_data
# <internal:core> core/module.rb:103:in `const_defined?'
# /Users/nirvdrum/dev/workspaces/truffleruby-ws/graal/sdk/mxbuild/darwin-aarch64/GRAALVM_A33290E019_JAVA11/graalvm-a33290e019-java11-22.3.0-dev/Contents/Home/languages/ruby/lib/truffle/truffle/cext.rb:1176:in `rb_define_class_under'
# define.c:27:in `rb_define_class'
# /Users/nirvdrum/dev/workspaces/truffleruby-ws/graal/sdk/mxbuild/darwin-aarch64/GRAALVM_A33290E019_JAVA11/graalvm-a33290e019-java11-22.3.0-dev/Contents/Home/languages/ruby/lib/gems/gems/memcached-1.8.0/ext/rlibmemcached_wrap.c:1737:in `Init_rlibmemcached'
# <internal:core> core/kernel.rb:226:in `gem_original_require'

The problematic code no longer exists in the memcached gem, but there hasn't been a release in over seven years. Even if we can convince the authors to release one, its master branch is set to 2.0.0.alpha, which would preclude it from an automatic update for most dependency graphs as it's a major version bump.

@nirvdrum nirvdrum added the cexts label Sep 30, 2022
@eregon
Copy link
Member

eregon commented Sep 30, 2022

rb_define_module_under already supports that, see

Truffle::CExt.rb_define_module_under(IO, 'generic_readable').module_eval do
. So it should be fairly easy to support it for rb_define_class too. PR welcome.

@nirvdrum
Copy link
Collaborator Author

nirvdrum commented Sep 30, 2022

I meant to assign this to myself. I fixed it just recently as part of a larger PR to run the memcached gem.

@nirvdrum nirvdrum self-assigned this Sep 30, 2022
@nirvdrum
Copy link
Collaborator Author

Fixed by cb44f1b.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants