- Notifications
You must be signed in to change notification settings - Fork587
Clone dirhandles without fchdir#23019
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
I think it's one reasonable fix, though I think it would be an entry in incompatible changes in perldelta. I'm not sure it's safe for multiple threads to readdir() from the same underlying fd: It's UB for both parent and child of a fork() to read from their corresponding copies of the From my testing with simple test code, glibc gets confused about the telldir() position for the new handle. One option might be to Of course, the simplest option is to just not pass the |
It's not, but the same is true across forks. The same is also true across threads for filehandles, really. This all falls firmly in "doctor it hurts when I poke into my eyeballs" IMO. |
Any movement here? |
I suspect I know how to write the missing parts in a fairly short time, but I'm not sure I'd be comfortable including it this late in the release cycle |
Note that@vinc17fr has justposted to oss-security regarding#23010. |
fa1e010
toa8f1068
CompareUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
@@ -199,6 +199,7 @@ d_fd_macros='define' | |||
d_fd_set='define' | |||
d_fdclose='undef' | |||
d_fdim='undef' | |||
d_fdopendir='undef' |
khwilliamsonMay 23, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
ShouldHAS_FDOPENDIR
be added tometaconfig.h
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I suspect not, but@Tux would know for sure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
As far as I can tell it only matters when regenerating Configure from metaconfig anyway. So I propose we leave it out for now and if it turns out to be necessary Tux can add it later when he comes back from his vacation.
Given that Windows has its own logic for dirhandle dup’ing, that I’ve discussed with@book and we agreed to drop the |
I concur that preserving the |
These tests makes assumptions that are only true for the current fchdirbased implementation of dirhandle cloning. In particular that the cloneddirhandle is entirely separate from the original. This is notappropriate for the upcoming fdopendir based implementation.
This uses fdopendir and dup to dirhandles. Unlike the fchdir approachthese handles share descriptor position among threads.
This is no longer needed now that the fdopendir implementation exists.
5c2e757
intobleadUh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
This is a WIP for fixing#23010 based on@ilmari's suggestion. There currently are two problems with it.
fdopendir
t/op/threads-dirh.t
fails because it's assuming that the dirhandles in different threads are independent. Given that the same isn't true of filehandles, I think this is the wrong thing to aim at anyway.