[PATCH] pwclient: Fix silent crash on python 2

Stephen Finucane stephen at that.guru
Wed Apr 5 20:20:29 AEST 2017


On Wed, 2017-04-05 at 11:15 +0100, Stephen Finucane wrote:
> On Tue, 2017-03-28 at 11:26 +0200, Robin Jarry wrote:
> > Replacing sys.stdout and sys.stderr can cause obscure crashes when
> > trying to write non unicode data. The interpreter is terminated
> > with
> > SIGINT without any specific error writen on the console.
> > 
> >   rt_sigaction(SIGINT, {SIG_DFL, [], SA_RESTORER, 0x7f964820e8d0},
> >   {0x559f50, [], SA_RESTORER, 0x7f964820e8d0}, 8) = 0
> > 
> > This happens easily when there is an untrapped exception which
> > should
> > lead to printing a traceback on stderr.
> > 
> > To fix this, the only way is to make sure that the PYTHONIOENCODING
> > env
> > variable is set *before* starting the interpreter as the
> > initialization
> > is made very early on and the encoding cannot be set or modified
> > after.
> > 
> > On python 3, the default IO encoding is already properly set
> > according
> > to locale.
> > 
> > Fixes: 046419a3bf8f ("pwclient: Fix encoding problems")
> > Signed-off-by: Robin Jarry <robin.jarry at 6wind.com>
> 
> I've no idea how I could even go about testing this. However, it
> looks
> sane and you've tested it locally so...
> 
> Acked-by: Stephen Finucane <stephen at that.guru>
> 
> ...and applied.

Actually, I take that back. Let's see if there's a less hacky way to do
this. Seems this is a fairly common problem with a few fixes available.
Would a fix like [1] do the job?

Also, could you provide some guidance as to how I could reproduce the
issue myself? Is the Patchwork instance using Python 2 or 3? What
environment is pwclient running in?

Stephen

[1] http://stackoverflow.com/a/11742574/613428

> _______________________________________________
> Patchwork mailing list
> Patchwork at lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/patchwork



More information about the Patchwork mailing list