Skip to content

Conversation

@e-ikuta
Copy link
Contributor

@e-ikuta e-ikuta commented Oct 22, 2024

Problem

As the related PR below, use of Dir.chdir is not thread-safe. This usage was causing exceptions to be raised when running on Puma and in other multi-threaded environments.

Related:

How to fix

This patch replaces Dir.chdir with thread-safe File.open method.

Additional information

This patch also removes @@mutex, which became unnecessary.

@alpaca-tc
Copy link

@johnnyshields @pitbulk If everything looks good to you, I would greatly appreciate it if you could consider merging this PR 😄

In the service I manage, we occasionally encounter a rare issue where file reading fails with an error in production. After investigating, we identified that the root cause is a Dir.chdir call in another thread, which changes the current working directory unexpectedly.

This PR would resolve the issue and ensure stable file reading.

スクリーンショット_2025-01-08_18_42_39-2

@johnnyshields
Copy link
Collaborator

@pitbulk lgtm, please merge.

@pitbulk pitbulk merged commit 130b829 into SAML-Toolkits:master Jan 10, 2025
36 checks passed
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.

4 participants