-
Notifications
You must be signed in to change notification settings - Fork 19
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
Incompatibility with kt-paperclip #306
Comments
Hi @jwoodrow, Can you provide more context in terms of what machine you are running this on (Mac/Linux distro, are you on an x86 or ARM machine?). Would also like to know if you can provide a minimal script that reproduces the error and which command you've used to run it. I've never heart of kt-paperclip or factorybot before, and I don't know which codebase you're running this on, so I wouldn't know how to reproduce this issue. |
Hi @maximecb, I'm currently away from my work computer so I can't provide a reproduction context, but I can try and work on that starting tomorrow. For the other questions, I'm running in a x86 ubuntu docker image and kt-paperclip is the replacing gem for paperclip which was the predecessor of active_storage before it came to be. The error itself appears during the validation process it seems. My first instinct is that there seems to be some issues with how Symbols are managed by unit because I've also encountered another similar issue where a gem used for json validations said there was no gsub method defined for a given symbol 🤔 I'll try and get you a reproduction repo up and running when I can (probably using docker so you can reproduce it more consistently) |
If you're able to provide us with the smallest possible script that reproduces the problem, that will help us a lot in diagnosing and fixing the issue. If there's something wrong with the way we handle symbols, that is definitely something we want to fix. |
I've been trying to reproduce using a newly created docker container and a minimal setup but it doesn't seem to be producing the error we're encountering on our main codebase. Which makes me thing, maybe we've got something else in our code which might be causing this issue, but with the size of it I think this might be a hard issue to debug for us so we might have to make a pass on yjit unfortunately for us 😞 |
Ok, well, if there is an issue with symbols, it will probably get fixed eventually when we can get a repro from another source :) |
Possibly related: we had something happen to us inconsistently but frequently in CI that went away as soon as we disabled YJIT. We haven't seen this in production and haven't been able to reproduce it on our development machines: |
I suggest trying a build of YJIT enabled Ruby off of the master branch. We've landed a couple of bug fixes since the 3.0 release that haven't been released yet. You can follow instructions to build from a checkout, or use https://github.com/rbenv/ruby-build with a checkout or a nightly snapshot release tar ball. There are also nightly builds of container images available at https://hub.docker.com/r/rubylang/ruby. |
@geoffharcourt if you have the time, checking if this bug is fixed by building ruby master as Alan suggested would be very helpful. |
FYI -- at TableCheck we're running kt-paperclip and YJIT in production and not seeing any issues so far. |
Thanks for the feedback @johnnyshields. Also very happy to hear that you are running YJIT in production :) Will leave this issue open for a little bit longer, just in case anyone else has anything to report. |
Apologies for not running the test sooner, our CI system isn't set up to run Ruby from the master branch and we've only been able to produce this issue so far in CI. |
Hi all 👋 - I can reproduce this (or very similar) issue in our local test suite (rails 6.1.x / ruby 3.2.1 yjit / kt-paperclip). Interestingly it only fails if I run the suite or multiple tests files/methods at once. It doesn't fail if I run the single test method (e.g. rails test path/to/test.rb:134) @maximecb can you confirm if the fixes you speak of are a part of 3.2.1 or should I attempt with master? (Also hey there @geoffharcourt - long time. Hope you're well!) |
We've merged multiple bug fixes as part of 3.2.1. You could start with that one. Let us know if that fixes the issue or not. If neither 3.2.1 or master fixes the issue, we could potentially pair with you to try and diagnose the problem. |
I’ve seen it fail with both 3.2.0 and 3.2.1. I’m open to pairing. I usually work EST 9-5. Please let me know how best we can schedule a time. Thanks! |
Tentatively Tuesday, Wednesday or Thursday in the afternoon would work best for us. Would that work for you as well? We typically use Tuple for pairing, but we could use another solution if you prefer another platform. You'll need to have the rust toolchain and lldb or gdb installed. |
Previously, YJIT failed to put the stack into the correct shape when `BasicObject#send` calls an alias method for the send method itself. This can manifest as strange `NoMethodError`s in the final non-send receiver, as [seen][1] with the kt-paperclip gem. I also found a case where it makes YJIT fail the stack size assertion while compiling `leave`. YJIT's `BasicObject#send` implementation already rejects sends to `send`, but didn't detect sends to aliases of `send`. Adjust the detection and reject these cases. Fixes [Bug #19464] [1]: Shopify/yjit#306
Previously, YJIT failed to put the stack into the correct shape when `BasicObject#send` calls an alias method for the send method itself. This can manifest as strange `NoMethodError`s in the final non-send receiver, as [seen][1] with the kt-paperclip gem. I also found a case where it makes YJIT fail the stack size assertion while compiling `leave`. YJIT's `BasicObject#__send__` implementation already rejects sends to `send`, but didn't detect sends to aliases of `send`. Adjust the detection and reject these cases. Fixes [Bug #19464] [1]: Shopify/yjit#306
Previously, YJIT failed to put the stack into the correct shape when `BasicObject#send` calls an alias method for the send method itself. This can manifest as strange `NoMethodError`s in the final non-send receiver, as [seen][1] with the kt-paperclip gem. I also found a case where it makes YJIT fail the stack size assertion while compiling `leave`. YJIT's `BasicObject#__send__` implementation already rejects sends to `send`, but didn't detect sends to aliases of `send`. Adjust the detection and reject these cases. Fixes [Bug #19464] [1]: Shopify/yjit#306
Hi there! Alan just merged a PR which he believes may fix this problem. If someone could test whether the bug is fixed by commit 0eb634a, that would be very helpful. Have a great week everyone :) |
The commit landed patches 3.2.1 cleanly, so you can try it without making your app compatible with the latest development version of Ruby. Here is how to build with the patch (the build takes less than 10 minutes!): If you use ruby-install ruby 3.2.1 \
--jobs 8 \
--no-reinstall \
--install-dir ~/.rubies/ruby-yjit-send-fix \
--patch https://github.com/ruby/ruby/commit/0eb634ae73cb327ede833b72492f912792a4a9d5.patch \
-- --enable-yjit If you use # make sure `rustc` is available and works
rbenv install --patch 3.2.1 \
< <(curl --proto '=https' --tlsv1.2 -sSf https://github.com/ruby/ruby/commit/0eb634ae73cb327ede833b72492f912792a4a9d5.patch) Depending on your setup, you might not even need to reinstall the bundle for your Rails app when switching to the patched version. Let us know how it goes if you do decide to give this a go! It'd be valuable feedback for us and for the release manager for the |
@maximecb @XrXr I managed to get ruby built from master downloaded here https://github.com/ruby/ruby - which seems to resolve this issue - at least, our test suite has passed. Any guess as to when 3.2.2 might drop? It'll be much easier to further test this patch with a released version. Thank you! |
Generally, the branch maintainer decides the timing and the contents of releases. I think @nurse is the current maintainer of the
Thank you for testing! |
YJIT: Detect and reject `send(:alias_for_send, :foo)` Previously, YJIT failed to put the stack into the correct shape when `BasicObject#send` calls an alias method for the send method itself. This can manifest as strange `NoMethodError`s in the final non-send receiver, as [seen][1] with the kt-paperclip gem. I also found a case where it makes YJIT fail the stack size assertion while compiling `leave`. YJIT's `BasicObject#__send__` implementation already rejects sends to `send`, but didn't detect sends to aliases of `send`. Adjust the detection and reject these cases. Fixes [Bug #19464] [1]: Shopify/yjit#306 --- test/ruby/test_yjit.rb | 20 ++++++++++++++++++++ yjit/src/codegen.rs | 25 ++++++++++--------------- 2 files changed, 30 insertions(+), 15 deletions(-)
Hi, first off good work on YJIT.
I've been trying to upgrade to ruby 3.2 with YJIT enabled and noticed some issues with the kt-paperclip when used with rails.
We have an old model we haven't attempted to migrate to active_storage because of the sheer size of this model and so we have kt-paperclip still in the project for this. In our demo generation suite (using factorybot) we end up using the
model_instance.attachment.assign
method which then calls some validations but doing so seems to completely break when using yjit.Here is the error and the stack trace if it can help:
I know this is linked to YJIT because if I remove the
RUBYOPT="--enable-yjit"
before running the demo generation then everything works fine.I don't understand exactly why this is happening, but I'm guessing/hoping I'm not the only one encountering issues using YJIT + kt-paperclip.
Maybe this is an issue I should raise on the kt-paperclip repo but I have a feeling it's more like some missing implementations in YJIT than kt-paperclip being broken (since it still works fine with the default cruby). Any insight into resolving this would be welcome ! 👋
The text was updated successfully, but these errors were encountered: