in reply to Perl jumps to END logic after fileno (Win32)
Without a self-contained sample, I can speculate that the filehandle you're calling fileno with is broken, or that something is independently stopping your script from running. Apart from those wild guesses, you're going to have to provide us with a bit more information.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl jumps to END logic after fileno (Win32)
by dchidelf (Novice) on Aug 09, 2017 at 20:51 UTC | |
Alright, so in looking deeper at the warnings I am receiving it seems as though windows is likely reusing the OS level filehandle I am pulling out from under the Perl handle via my hardclose logic. Then when perl implicitly closes the Perl handle it is closing whatever ended up reusing that OS handle causing unspecified behavior. So perhaps to avoid this I should ask for assistance in accomplishing my goal. I want to spawn a thread then close a handle that was open in the main thread prior to the creation of the thread. In experimenting with this I was not able to have the process actually release the OS file handle. I don't remember the details, but I was not able to call close from both the main thread and "child" thread. | [reply] |
by Anonymous Monk on Aug 09, 2017 at 23:49 UTC | |
Hi, What?
| [reply] [d/l] |
by dchidelf (Novice) on Aug 10, 2017 at 18:41 UTC | |
Thanks. At first I was responding with "it's not that easy", but this actually seems like it might have helped. I am creating the threads from within a "constructor" in a package and need to close a file handle that is being assigned to a scalar rather than a type glob. Since the scalar is scoped to the scope of the subroutine and the thread logic was outside of that function I was attempting to pass the handle as an argument to the thread, which fails in various ways. If I declare the thread logic in an anonymous sub nested inside the "constructor" it seems like I will be able to just reference the scalar within that same scope and be able to close the copy that gets dup'd into the new thread. Test mockup works, I just need to test it with pipes and all the other details
| [reply] [d/l] |
by Anonymous Monk on Aug 10, 2017 at 23:33 UTC | |
|
Re^2: Perl jumps to END logic after fileno (Win32)
by dchidelf (Novice) on Aug 08, 2017 at 22:06 UTC | |
I have been able to narrow down the code a little. In doing so I can see that my call to threads->create is attempting to close half of my pipe that I am passing to it. Due to Win32 process peculiarities I need to forcefully close some file handles using a hardclose function. I also needed to close the STDOUT/STDERR handles in my thread, so I wasn't seeing the warnings. Somehow the combination of the warnings and hardcloses causes file descriptors to get corrupted on *SOME* systems. It is possibly a race condition, as the Perl software is identical between the systems I test on, yet one fails within the first 50 iterations of the loop in this test, whereas the other system has processed over 40000 iterations of the loop with no issues (aside from the warning messages). The behavior also changes when removing the print statements. failure is either the report that either STDOUT or STDERR are gone, or message that new_from_fd failed
| [reply] [d/l] |
by Anonymous Monk on Aug 09, 2017 at 01:32 UTC | |
It is possibly a race condition, as the Perl software is identical between the systems I test on, yet one fails within the first 50 iterations of the loop in this test, whereas the other system has processed over 40000 iterations of the loop with no issues (aside from the warning messages) ... failure is either the report that either STDOUT or STDERR are gone, or message that new_from_fd failed Hi, What is "perl software" and "systems" (versions)? I cannot reproduce on strawberry-perl-5.18.2.2-32bit-portable on old winxp machine | [reply] |
by dchidelf (Novice) on Aug 09, 2017 at 13:02 UTC | |
It is Strawberry Perl 5.24.0 (64-bit) on Windows 7 and Windows 10. My Windows 7 laptop does not experience any issues, but some other Windows 7 systems and a Windows 10 test system I have do. Each of the systems that experience issues have SSD drives. So far that has been the only thing we have found in common with the failing systems. I tried with an old 5.16.3 Version of perl I had on my system and the warnings go away. So somewhere between 5.16.3 and 5.24.0 the changes with threading have added logic that is attempting to close some of my handles or at least is warning about failing. Here are those warningsTesting with 5.16.3 on a system that experiences failures, it still fails, but without the "unable to close filehandle" warning messages. | [reply] [d/l] |