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
Carp::confess loses $! on Windows #10940
Comments
From Mark@Overmeer.net(no detailed Perl -V information because the bug is on Windows which The following script catches the die() used by Carp::confess. Only #!/usr/bin/perl use Carp; print "--> without \\n\n"; Output on all platforms except Windows (afaik) as expected: --> without \n --> with \n Output when run on Strawberry Perl 5.12.1.0 (x64) (and other --> without \n -- Mark Overmeer MSc MARKOV Solutions |
From @kmx
The same output with all: -- |
The RT System itself - Status changed from 'new' to 'open' |
From @tonycozOn Wed Jan 12 04:29:05 2011, kmxx wrote:
5.18: C:\Users\tony\play>perl -E "$SIG{__DIE__} = sub { say qq(error: $!) }; blead: C:\Users\tony\play>\testperlx\bin\perl -E "$SIG{__DIE__} = sub { say Nothing leaps out at me as the cause of the fix though. Tony |
From cm.perl@abtela.comI believe this was diagnosed in #116118. To summarize, the cause is $arg =~ s/([[:cntrl:]]|[[:^ascii:]])/sprintf("\\x{%x}",ord($1))/eg; On recent versions of Windows, any call to atoi clears $! (and possibly Thread 116118 got somewhat sidetracked by other considerations but I Christian Le 27/08/2013 08:17, Tony Cook via RT a écrit :
|
From @nwc10On Tue, Aug 27, 2013 at 11:20:56AM +0200, Christian Millour wrote:
I'm curious - is a violation of the C standard?
I missed that thread - I'll have proper look now. Nicholas Clark |
From @tonycozOn Tue, Aug 27, 2013 at 10:30:21AM +0100, Nicholas Clark wrote:
Yes, it's a violation under both C89 and C99. Standard C library functions may not set errno to 0 (except Tony |
From cm.perl@abtela.comLe 27/08/2013 11:43, Tony Cook a écrit :
[Tony, sorry for the duplicate response. I'll try to be more careful] I can't find the relevant quote in C89 or C99 but on Linux, man 3 errno The <errno.h> header file defines the integer variable errno, which From the first sentence it seems that the boundary between syscalls and Christian |
From zefram@fysh.orgTony Cook via RT wrote:
I wouldn't call this a "fix". Carp has never guaranteed to preserve -zefram |
From cm.perl@abtela.comLe 27/08/2013 12:49, Zefram a écrit :
opinions on this seem to differ. As mentioned in #116118 : Note incidentally that dist/Carp/t/Carp.t explicitly checks that Since I tend to use the tests as supplemental/definitive documentation Christian |
From cm.perl@abtela.comLe 27/08/2013 13:18, Christian Millour a écrit :
To expand on this, I believe it is essential that croak and confess do For the same reason I believe that croak and confess should not clobber Christian |
From zefram@fysh.orgChristian Millour wrote:
Interesting argument. You've neatly addressed the obvious issue that
If this is to be a deliberate feature, it should be documented, it should -zefram |
From cm.perl@abtela.comLe 27/08/2013 15:11, Zefram a écrit :
That is certainly a quick fix, one that I suggested in #116118 and have The clobbering of $! by croak/confess is caused by the new behavior of Regarding thorough tests, I absolutely concur. One (small) problem is Christian |
From @nwc10On Tue, Aug 27, 2013 at 12:24:44PM +0200, Christian Millour wrote:
I think that it may be possible to eliminate the calls to atoi() for getting
The value of errno is zero at program startup, but is never set to zero 7.5.3 in a late draft of C99. Same in a draft of C11, except that the footnote Nicholas Clark |
From @cpansproutOn Wed Aug 28 04:43:57 2013, nicholas wrote:
Still, shouldn’t we wrap atoi on non-compliant systems? Otherwise we -- Father Chrysostomos |
From @LeontOn Thu, Aug 29, 2013 at 9:02 AM, Father Chrysostomos via RT <
I agree. This is just waiting to bite us somewhere else. Leon |
From cm.perl@abtela.comLe 29/08/2013 11:29, Leon Timmermans a écrit :
Which leaves only the problem of how best to wrap it. The difficulty { So Windows is not so terribly wrong in bundling the reset of errno with If the same coder is intent on preserving the current errno (because she { This mess is not Windows-specific BTW. So maybe the best solution for int Perl_atoi(char const *s, int * overflow_p) { possibly together with an optimized version for those users that do not int Perl_atoi_ignore_overflow(char const *s) { So that the responsibility to handle overflow would be put clearly in This would allow Windows XS code to use the native atoi, warts and all, Of course this is pretty disgusting (and there might be a much better It is all a matter of choosing the way we will get bitten in the future ;-) |
From @LeontOn Thu, Aug 29, 2013 at 2:30 PM, Christian Millour <cm.perl@abtela.com>wrote:
atoi() is not documented to use errno to indicate errors, in fact "If the
That's a perfectly sensible approach using strtol and friends, as they're Leon |
From cm.perl@abtela.comLe 29/08/2013 15:03, Leon Timmermans a écrit :
I stand corrected, thank you. Makes me wonder though whether the use of atoi instead of strtol in core Christian |
From zefram@fysh.orgChristian Millour wrote:
With $RefArgFormatter and CARP_TRACE, Carp now explicitly invokes -zefram |
From cm.perl@abtela.comLe 29/08/2013 17:56, Zefram a écrit :
I agree fully. However what atoi gets up to might still matter in other Taisha:/cygdrive/g/perls/blead/git/win32 $ cat # from use of atoi in mg.c $! = 99; $! = 99; $! = 99; $! = 99; $! = 99; # from use of atoi in regcomp.c $! = 99; |
From zefram@fysh.orgI wrote:
Done as cbd58ba. -zefram |
From @cpansproutOn Thu Aug 29 14:04:13 2013, zefram@fysh.org wrote:
Hence, I am marking this as resolved, since this ticket is about Carp -- Father Chrysostomos |
@cpansprout - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#81586 (status was 'resolved')
Searchable as RT81586$
The text was updated successfully, but these errors were encountered: