-
Notifications
You must be signed in to change notification settings - Fork 559
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
Perl enters infinite loop with -d:Trace and binmode(STDERR, encoding(UTF-8)) #15921
Comments
From @wolfsageOriginally brought to my attention by tudor on #moose: These are fine: perl -d:Trace -e 'binmode(STDERR, ":encoding(UTF-8)");' 2>&1 These enter infinite loops: perl -d:Trace -e 'binmode(STDERR, ":encoding(UTF-8)");' 2>&1 | tee out.txt CPU is at 100%, and if I attach to perl with gdb and grab a backtrace: (gdb) bt Also tested with 5.24.1, and blead. -- Matthew Horsfall (alh) |
From @shlomifOn Fri, 07 Apr 2017 06:13:38 -0700
Just for the record - I can reproduce this problem on Mageia x86-64 v6 (Linux) shlomif@telaviv1:~$ perl -v This is perl 5, version 22, subversion 3 (v5.22.3) built for Copyright 1987-2017, Larry Wall Perl may be copied only under the terms of either the Artistic License or the Complete documentation for Perl, including FAQ lists, should be found on shlomif@telaviv1:~$ Regards, Shlomi Fish -- Shlomi Fish http://www.shlomifish.org/ How many “one-liners” do I actually write? I don’t know; maybe a couple dozen |
The RT System itself - Status changed from 'new' to 'open' |
From @tonycozOn Fri, 07 Apr 2017 06:13:38 -0700, alh wrote:
I don't have Devel::Trace installed (I'm working with an uninstalled blead tree), but I see an infinite loop with -Dt with a -DDEBUGGING build too. I expect what's happening in your case is Devel::Trace is trying to trace the call to $encoding->renew() or $encoding->needs_lines() (both of which are done with G_EVAL), writing to STDERR, which tries to use the partly initialised PerlIO::encoding layer and dies, which tries to write to the stream calling PerlIO_flush(). This loops because PerlIO::encoding prevents recursive calls to $encoding->encode(), losing the output rather than recursving infinitely. With -Dt (in blead at least) it seems to get stuck earlier in the call to Encode::find_encoding(), but you get a similar result. The debugger doesn't seem to have a problem with this code, presumably because it either clones STDERR or opens the TTY. Possible fixes: - Devel::Trace could clone STDERR and write to that clone, this should work for older perls too. - perl's -D switch could do something similar. - perl (perhaps in PerlIO::encoding) could disable both -Dt tracing and debugger tracing when pushing a layer onto or writing to STDERR. This might be a bit too magical though. Tony |
Migrated from rt.perl.org#131115 (status was 'open')
Searchable as RT131115$
The text was updated successfully, but these errors were encountered: