Skip to content

Dir.chdir conflicting warning and error#8251

Merged
enebo merged 1 commit intojruby:masterfrom
edipofederle:dir-chdir-thread-access
May 30, 2024
Merged

Dir.chdir conflicting warning and error#8251
enebo merged 1 commit intojruby:masterfrom
edipofederle:dir-chdir-thread-access

Conversation

@edipofederle
Copy link
Contributor

No description provided.

@edipofederle edipofederle force-pushed the dir-chdir-thread-access branch 6 times, most recently from 28b4e65 to 59269d8 Compare May 22, 2024 11:58
@edipofederle
Copy link
Contributor Author

@enebo could you please help me understand/check if these failing tests are really related with this PR changes? since sometimes it pass, sometimes not.

Thanks

@edipofederle edipofederle marked this pull request as ready for review May 23, 2024 11:01
Copy link
Member

@enebo enebo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can probably put this as a field on Ruby (with a more specific name than currentThread) and otherwise I think this looks good.

The lone failure in sequel is unrelated to this PR.

@enebo
Copy link
Member

enebo commented May 23, 2024

@edipofederle @headius Actually I have other concerns with this now that I think about it. If you have an n-thread server which all was calling out to a process with the same directory this would lock the entire server to becoming synchronous. If we allowed all threads which called processes in the same directory to run it would alleviate some of this concern but I now question if this is a good idea or not.

@enebo
Copy link
Member

enebo commented May 28, 2024

Just some scenarios I thought about from the above comment:

  1. n Dir.chdir to the SAME dir means none of those other threads can execute at the same time
  2. one Dir.chdir which never executes would block any other Dir.chdir from ever exectuting.

I am not sure what the right thing to do here is but the second problem seems like it will generate a different issue. I half wonder if there is some solution where every thread externally tracks chdir and if anything using chdir (like process launch) it somehow gets used instead. This I can already see would not fix call outs to external Java libraries doing processes but I feel like that problem is not solvable.

@enebo
Copy link
Member

enebo commented May 30, 2024

@edipofederle This is the issue to follow for this https://bugs.ruby-lang.org/issues/15661

So I think you must have read this issue based on how the PR was written. I think just moving currentThread to Ruby so it is not a staticfield and I think the lock should be removed.

In particular https://bugs.ruby-lang.org/issues/15661#note-16 should work (or at least the comments make me think it should work). With the PR as it is I think it will warn then dead lock.

@edipofederle edipofederle force-pushed the dir-chdir-thread-access branch from 59269d8 to 21686ca Compare May 30, 2024 16:29
@enebo enebo merged commit 225028a into jruby:master May 30, 2024
@enebo
Copy link
Member

enebo commented May 30, 2024

@edipofederle thanks for bearing with me on that. We got there in the end. Thanks for the contribution!

@enebo enebo added this to the JRuby 9.4.8.0 milestone May 30, 2024
@edipofederle edipofederle deleted the dir-chdir-thread-access branch May 30, 2024 18:16
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 this pull request may close these issues.

2 participants