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

`synchronize': can't be called from trap context (ThreadError) #46785

Closed
aaronjensen opened this issue Dec 21, 2022 · 4 comments
Closed

`synchronize': can't be called from trap context (ThreadError) #46785

aaronjensen opened this issue Dec 21, 2022 · 4 comments
Labels
more-information-needed When reporter needs to provide more information

Comments

@aaronjensen
Copy link
Contributor

aaronjensen commented Dec 21, 2022

Steps to reproduce

I reported this to guard/listen#565 as well, in case the fix needs to be there.

Use:

  config.file_watcher = ActiveSupport::EventedFileUpdateChecker

And puma as your web server. The warning happens randomly, but when it does you will see:

my-app/gems/ruby/3.1.0/gems/actionview-7.0.4/lib/action_view/helpers/tag_helper.rb:189: warning: Exception in finalizer #<Proc:0x000000010852fb80 my-app/gems/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/evented_file_update_checker.rb:91>
my-app/gems/ruby/3.1.0/gems/listen-3.7.1/lib/listen/fsm.rb:80:in `synchronize': can't be called from trap context (ThreadError)
        from my-app/gems/ruby/3.1.0/gems/listen-3.7.1/lib/listen/fsm.rb:80:in `transition!'
        from my-app/gems/ruby/3.1.0/gems/listen-3.7.1/lib/listen/fsm.rb:104:in `transition_with_callbacks!'
        from my-app/gems/ruby/3.1.0/gems/listen-3.7.1/lib/listen/fsm.rb:72:in `transition'
        from my-app/gems/ruby/3.1.0/gems/listen-3.7.1/lib/listen/listener.rb:103:in `stop'
        from my-app/gems/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/evented_file_update_checker.rb:111:in `stop'
        from my-app/gems/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/evented_file_update_checker.rb:92:in `block in finalizer'
       ... additional unrelated application stacktrace ...

It appears to be action_view/cache_expiry that is being finalized (the below is the caller of initialize that I store to print again in the finalizer.

my-app/gems/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/evented_file_update_checker.rb:45:in `new'
my-app/gems/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/evented_file_update_checker.rb:45:in `initialize'
my-app/gems/ruby/3.1.0/gems/actionview-7.0.4/lib/action_view/cache_expiry.rb:48:in `new'
my-app/gems/ruby/3.1.0/gems/actionview-7.0.4/lib/action_view/cache_expiry.rb:48:in `block in execute_if_updated'
my-app/gems/ruby/3.1.0/gems/actionview-7.0.4/lib/action_view/cache_expiry.rb:42:in `synchronize'
my-app/gems/ruby/3.1.0/gems/actionview-7.0.4/lib/action_view/cache_expiry.rb:42:in `execute_if_updated'
my-app/gems/ruby/3.1.0/gems/actionview-7.0.4/lib/action_view/cache_expiry.rb:15:in `block in run'
my-app/gems/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
my-app/gems/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/dependencies/interlock.rb:41:in `permit_concurrent_loads'
my-app/gems/ruby/3.1.0/gems/actionview-7.0.4/lib/action_view/cache_expiry.rb:14:in `run'
my-app/gems/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/execution_wrapper.rb:29:in `before'

Expected behavior

No warning, it seems like stopping listen in a finalizer is error prone because those may run in traps.

Actual behavior

The warning

System configuration

Rails version: 7.0.4

Ruby version: 3.1.2

@rails-bot
Copy link

rails-bot bot commented Mar 21, 2023

This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails team are limited, and so we are asking for your help.
If you can still reproduce this error on the 7-0-stable branch or on main, please reply with all of the information you have about it in order to keep the issue open.
Thank you for all your contributions.

@rails-bot rails-bot bot added the stale label Mar 21, 2023
@ksweetie
Copy link

I'm seeing the same error using Rails/Puma/ViewComponent/Listen:

/Users/kevinsweet/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activesupport-7.0.4.3/lib/active_support/ordered_options.rb:44: warning: Exception in finalizer #<Proc:0x0000000135bee3e0 /Users/kevinsweet/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activesupport-7.0.4.3/lib/active_support/evented_file_update_checker.rb:91>
/Users/kevinsweet/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/listen-3.8.0/lib/listen/fsm.rb:80:in `synchronize': can't be called from trap context (ThreadError)
	from /Users/kevinsweet/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/listen-3.8.0/lib/listen/fsm.rb:80:in `transition!'
	from /Users/kevinsweet/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/listen-3.8.0/lib/listen/fsm.rb:104:in `transition_with_callbacks!'
	from /Users/kevinsweet/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/listen-3.8.0/lib/listen/fsm.rb:72:in `transition'
	from /Users/kevinsweet/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/listen-3.8.0/lib/listen/listener.rb:103:in `stop'
	from /Users/kevinsweet/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activesupport-7.0.4.3/lib/active_support/evented_file_update_checker.rb:111:in `stop'
	from /Users/kevinsweet/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activesupport-7.0.4.3/lib/active_support/evented_file_update_checker.rb:92:in `block in finalizer'
	from /Users/kevinsweet/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activesupport-7.0.4.3/lib/active_support/ordered_options.rb:44:in `to_s'
	from /Users/kevinsweet/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/activesupport-7.0.4.3/lib/active_support/ordered_options.rb:44:in `method_missing'

@aaronjensen Did you happen to find a fix/workaround?

@rails-bot rails-bot bot removed the stale label Mar 22, 2023
@aaronjensen
Copy link
Contributor Author

@ksweetie I tested w/ main and didn't see it. Could you try that and see if it fixes it for you?

@zzak zzak added the more-information-needed When reporter needs to provide more information label Mar 28, 2023
@rails-bot
Copy link

rails-bot bot commented Apr 11, 2023

This issue has been automatically closed because there has been no follow-up response from the original author. We currently don't have enough information in order to take action. Please reach out if you have any additional information that will help us move this issue forward.

@rails-bot rails-bot bot closed this as completed Apr 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
more-information-needed When reporter needs to provide more information
Projects
None yet
Development

No branches or pull requests

3 participants