-
Notifications
You must be signed in to change notification settings - Fork 584
IO::Socket fails with Bareword error #20355
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
Comments
It looks like the code is not defensive enough for the parser on systems where EINVAL is not defined. This condition is only executed when $^O is MSWin32 so deferring the constant resolution to runtime as mentioned seems appropriate. |
But why is |
Is there any chance you could try with 1. the latest version of the IO::Socket module installed from CPAN (1.49), or 2. a more recent version of Perl? |
(note that neither Perl 5.20.2 nor the IO distribution it's bundled with can be updated at this point, so a fix would require doing one of the above regardless) |
@Grinnz We build from source so we can use the same version across all the platforms we build here at work (FreeBSD, linux, solaris, Aix, hpux). I'm not interested in a newer version for this bug. It is only for 5.20.2 and the bundle IO::Socket with that source. I looked at the source for Socket.pm online and I think the latest is even 1.50. And that still has a bareword. Whether or not the code is executed with $^O if MSWin32, it must pass the syntax check. And "strict subs" is active, so the error is seen. |
I have fixed the issue myself by updating the source. Just thought it might be helpful to update the actual source for future versions. |
My point is that Perl 5.20.2 and its included version of IO cannot be updated. So it is important to determine whether the issue is present in the current versions of Perl and IO, otherwise updating them is of no benefit. |
@Grinnz understood. But maybe change the source code where it can be updated. perl5.32.1 is installed on FreeBSD 13.1-RELEASE and it does not exhibit this error. And the barework is still there. It is version 1.43.
The version that is bundled with 5.20.2 is 1.45. |
On FreeBSD-13, I wrote the following program:
I then did a git checkout at tag
I then ran my program with that
I got neither errors nor warnings. I then used the I then re-ran the program with the same (
Once again, I got neither errors nor warnings. I cannot reproduce the problem reported in this ticket. I don't think there's any action for P5P to take. IMO the ticket is closable. |
The earlier comments from @Grinnz and @Leont suggest that you will only be able to reproduce it on a platform where EINVAL is undefined. So the question would be under what circumstances that is possible, and - based on the answer to that - whether it's something we should take responsibility for defending against. Another possible mitigation would be to have Errno detect the situation and define EINVAL to something else. |
I think the Errno::EINVAL bareword is a syntax error and should have a preceding & just like other references to &Errno:: in the same file. That's all. If you're not going to do anything about this, then feel free to close it. |
It's not a syntax error as long as EINVAL exists on the platform - which should be true on all platforms, so it's weird to have this issue as @Leont noted. |
I'm curious if it's because of this issue, which was fixed in 5.20.3: #14491 |
Note that if you have that issue, you have bigger problems than just EINVAL not being defined, and I would highly recommend upgrading to 5.20.3 if possible (it's a compatible release as it's the maintenance branch) |
On 9/27/22 17:32, David Quattlebaum wrote:
I think the Errno::EINVAL bareword is a syntax error and should have a
preceding & just like other references to &Errno:: in the same file.
That's all.
I haven't been following this closely, but it appears there is
resistance to adding the &, and I don't understand that resistance.
…
If you're not going to do anything about this, then feel free to close it.
—
Reply to this email directly, view it on GitHub
<#20355 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAA2DHZZ5V4QBYOD2GD5JGLWAN7ZPANCNFSM6AAAAAAQXCYR34>.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
I rebuilt perl 5.20.2 from source again, and installed all of the modules again and moved this data into production. It does not exhibit the problem I was seeing before. |
I found the problem. If I build perl using gcc (gcc version 10.3.0 (FreeBSD Ports Collection)) the problem with IO::Socket.pm shows up. Building with clang (FreeBSD clang version 13.0.0) does not show the problem. |
This is what I used to configure the perl that shows the failure:
And the gcc used was gcc10 |
Okay, at last something I can reproduce.
Would it be possible for you to test these scenarios?
Thank you very much. |
I'll begin these tests now. First 2 and 3 before I try to install gcc11 |
Building threaded perl on FreeBSD-13 at v5.20.2 using
|
Same error:
|
Same error as 2. |
And I got same failures with unthreaded build using
So it appears that when on FreeBSD-13, using Out of time today, but next steps might include:
|
&Errno::EINVAL isn't constant replaced:
I suspect the resistance is due to the cause being an already fixed bug (which I believe Devel::PatchPerl patches). Note the bug is Errno not providing EINVAL on a system that defines that value. |
|
Release Errno on CPAN and make IO released on CPAN depend on a sufficiently recent version. We could also change IO to use the Errno::EINVAL() form, which will fix this specific issue (but not all issues). The case reported here is only called on Win32 (it's a compilation error), but some of the XS specifically sets errno to EINVAL, and we test for that result, so there's other problems without a valid EINVAL too.
Yes, it's a problem with handling output from gcc, IIRC, it's not operating system specific. |
In #20355 (comment), @drq883, the original poster, reported getting a compilation error when (to oversimplify somewhat) he attempted to Given that the I had a FreeBSD-13 VM available, so I built perl-5.20.2 using my customary @Grinnz wondered if the problem was related to one corrected in #14491 in February 2015. As we'll see below, his hunch was correct. The OP and I were each able to demonstrate that the problem was specific to Working on FreeBSD-12 I was able to reproduce the problem with a perl-5.20.0 but not with perl-5.22.0 released about one year earlier. So the question then became: At what point in the 5.21 development cycle, building perl with a relatively recent Bisection points to this commit:
I personally don't have any |
It wasn't and isn't a bug in gcc. The problem was that with this input:
The gcc cpp went from producing output like this:
which the Errno_pm.PL parser could parse, to code like:
which the Errno_pm.PL parser could not parse, which left use with an empty list of error constants. Both outputs are completely valid for a C preprocessor - they form a valid input to a C compiler. You can see this happen with a recent gcc if you comment out the assignment in:
so it hasn't been "fixed" in gcc - it wasn't broken. So the fix for older perls is to use a fixed An alternative is to use Devel::PatchPerl, which includes the fix, but IO can't depend on that declaratively, though it could check at Makefile.PL time that Errno::EINVAL is available. |
@tonycoz, what changes, if any, do we need to make in the core distribution to resolve this ticket? |
I was tempted to look for a minimal version to depend on that implements the gcc switches that provoked this change, but other recent changes are also useful. Fixes Perl#20355
The most reasonable I think would be to move Errno from ext to dist, release that on CPAN, and make IO depend on Errno. Other options:
|
Module: IO::Socket
Description
When including the IO::Socket module using a perl5.20.2 built from source, we're seeing this output:
We traced it down to the code here:
If we prefix the
Errno::EINVALL
with a&
(as seen in other places in code), it works without error.Steps to Reproduce
We build perl from source then, use the resulting cpan to install a myriad modules. And when all that is done, we get the error. If I just build from source and build no modules, run something like this, it works:
However when we go thru all the gyrations to build source and modules, we get this output:
Expected behavior
It should just print:
Perl configuration
This is the perl -V that exhibits the error:
This is the perl that works:
The text was updated successfully, but these errors were encountered: