-
Notifications
You must be signed in to change notification settings - Fork 117
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
Invalid FFI::AutoPointer is causing infinite loop in Finalizer thread starting from JRuby 9.3.4 #854
Comments
as a fix for appsignal#854
We patched the appsignal gem with this change eazybi@bae84fd and now in production, we do not see anymore the Finalizer thread with an infinite loop in |
Thanks @rsim for the patch, we will take a look into that. |
The `appsignal_free_transaction` and `appsignal_free_data` Rust extension function calls were missing their argument definitions in the FFI declaration. These are the function definitions from the `appsignal.h` file, downloaded upon installation. ```c void appsignal_free_transaction(appsignal_transaction_t*); void appsignal_free_data(appsignal_data_t*); ``` Fixes #854 where users saw very high CPU usage because the function call was being retried indefinitely. Co-authored-by: Raimonds Simanovskis <raimonds.simanovskis@gmail.com>
I've created a PR for the fix you sent in here: #856 |
Looks like our CI didn't show us this issue because we don't test against JRuby 9.3, in which the commit that highlights this issue was added. I've created an issue to add JRuby 9.3 to our CI build in #858. |
The `appsignal_free_transaction` and `appsignal_free_data` Rust extension function calls were missing their argument definitions in the FFI declaration. These are the function definitions from the `appsignal.h` file, downloaded upon installation. ```c void appsignal_free_transaction(appsignal_transaction_t*); void appsignal_free_data(appsignal_data_t*); ``` Fixes #854 where users saw very high CPU usage because the function call was being retried indefinitely. Co-authored-by: Raimonds Simanovskis <raimonds.simanovskis@gmail.com>
We're hoping to release the fix for this next week. |
@rsim The fix for this has been released in Ruby gem 3.1.0. And we're already up to 3.1.2 now :) |
After upgrading from JRuby 9.3.3.0 to 9.3.6.0 we noticed that our Rails app with the appsignal gem consumes more CPU. From the thread dump we identified that the Java Finalizer thread is stuck in an infinite loop:
Infinite loop is caused by
checkCircularCause
which was added in jruby/jruby@bd2595c which solved jruby/jruby#7035. It seems that somehow circular exception cause loop is created which does not include the latest top exception.But further in the stack we can see that the root cause is
FFI::AutoPointer
atautopointer.rb:175
which callsand then
checkArity
fails for this call.As I found the
appsignal
gem definesFFI::AutoPointer
in three places:And these methods are defined as foreign functions in the following way:
As I see
appsignal_free_span
is defined with a:pointer
argument butappsignal_free_transaction
andappsignal_free_data
are defined without any arguments which I suspect is wrong.My guess is that when
FFI::AutoPointer
tries to call the finalizer code with eitherappsignal_free_transaction
orappsignal_free_data
then the method arity check fails (as it tries to call it with a pointer argument but they are defined without arguments). And now the newcheckCircularCause
method results in an infinite loop and exposes this problem, previously I suspect it was silently failing and was not noticeable.The text was updated successfully, but these errors were encountered: