* [PATCH] lib/bb/utils: fix set_process_name
@ 2016-07-12 15:15 Ross Burton
2016-07-12 15:20 ` Christopher Larson
0 siblings, 1 reply; 3+ messages in thread
From: Ross Burton @ 2016-07-12 15:15 UTC (permalink / raw)
To: bitbake-devel
With Python 3 create_string_buffer needs a bytes() not a str() but as we were
catching all exceptions nobody noticed.
[ YOCTO #9910 ]
Signed-off-by: Ross Burton <ross.burton@intel.com>
---
bitbake/lib/bb/utils.py | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index 0a1bf68..3bc2437 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -1444,9 +1444,8 @@ def set_process_name(name):
# This is nice to have for debugging, not essential
try:
libc = cdll.LoadLibrary('libc.so.6')
- buff = create_string_buffer(len(name)+1)
- buff.value = name
- libc.prctl(15, byref(buff), 0, 0, 0)
+ buf = create_string_buffer(bytes(name, 'utf-8'))
+ libc.prctl(15, byref(buf), 0, 0, 0)
except:
pass
--
2.8.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] lib/bb/utils: fix set_process_name
2016-07-12 15:15 [PATCH] lib/bb/utils: fix set_process_name Ross Burton
@ 2016-07-12 15:20 ` Christopher Larson
2016-07-12 23:00 ` Richard Purdie
0 siblings, 1 reply; 3+ messages in thread
From: Christopher Larson @ 2016-07-12 15:20 UTC (permalink / raw)
To: Ross Burton; +Cc: bitbake-devel@lists.openembedded.org
[-- Attachment #1: Type: text/plain, Size: 1242 bytes --]
On Tue, Jul 12, 2016 at 8:15 AM, Ross Burton <ross.burton@intel.com> wrote:
> With Python 3 create_string_buffer needs a bytes() not a str() but as we
> were
> catching all exceptions nobody noticed.
>
> [ YOCTO #9910 ]
>
> Signed-off-by: Ross Burton <ross.burton@intel.com>
> ---
> bitbake/lib/bb/utils.py | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
> index 0a1bf68..3bc2437 100644
> --- a/bitbake/lib/bb/utils.py
> +++ b/bitbake/lib/bb/utils.py
> @@ -1444,9 +1444,8 @@ def set_process_name(name):
> # This is nice to have for debugging, not essential
> try:
> libc = cdll.LoadLibrary('libc.so.6')
> - buff = create_string_buffer(len(name)+1)
> - buff.value = name
> - libc.prctl(15, byref(buff), 0, 0, 0)
> + buf = create_string_buffer(bytes(name, 'utf-8'))
> + libc.prctl(15, byref(buf), 0, 0, 0)
> except:
> pass
>
Why are we catching all exceptions, anyway? That's not usually a good idea.
--
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics
[-- Attachment #2: Type: text/html, Size: 2064 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] lib/bb/utils: fix set_process_name
2016-07-12 15:20 ` Christopher Larson
@ 2016-07-12 23:00 ` Richard Purdie
0 siblings, 0 replies; 3+ messages in thread
From: Richard Purdie @ 2016-07-12 23:00 UTC (permalink / raw)
To: Christopher Larson, Ross Burton; +Cc: bitbake-devel@lists.openembedded.org
On Tue, 2016-07-12 at 08:20 -0700, Christopher Larson wrote:
>
> On Tue, Jul 12, 2016 at 8:15 AM, Ross Burton <ross.burton@intel.com>
> wrote:
> > With Python 3 create_string_buffer needs a bytes() not a str() but
> > as we were
> > catching all exceptions nobody noticed.
> >
> > [ YOCTO #9910 ]
> >
> > Signed-off-by: Ross Burton <ross.burton@intel.com>
> > ---
> > bitbake/lib/bb/utils.py | 5 ++---
> > 1 file changed, 2 insertions(+), 3 deletions(-)
> >
> > diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
> > index 0a1bf68..3bc2437 100644
> > --- a/bitbake/lib/bb/utils.py
> > +++ b/bitbake/lib/bb/utils.py
> > @@ -1444,9 +1444,8 @@ def set_process_name(name):
> > # This is nice to have for debugging, not essential
> > try:
> > libc = cdll.LoadLibrary('libc.so.6')
> > - buff = create_string_buffer(len(name)+1)
> > - buff.value = name
> > - libc.prctl(15, byref(buff), 0, 0, 0)
> > + buf = create_string_buffer(bytes(name, 'utf-8'))
> > + libc.prctl(15, byref(buf), 0, 0, 0)
> > except:
> > pass
> >
> Why are we catching all exceptions, anyway? That's not usually a good
> idea.
The variety of ways cdll and direct syscalls can fail is potentially
quite large in this code block and if this doesn't work, its not really
a big deal, its there for debugging so at the time it seemed reasonable
just to continue if it fails. If someone wants to figure out the
different cdll failure modes on various distros, I'm happy for them to
do so and send a patch. Obviously it did hurt in the python3 transition
but we won't do that every day...
Cheers,
Richard
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-07-12 23:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-12 15:15 [PATCH] lib/bb/utils: fix set_process_name Ross Burton
2016-07-12 15:20 ` Christopher Larson
2016-07-12 23:00 ` Richard Purdie
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.