[libvirt] [PATCH v2 5/5] Prevent more compiler optimization of mockable functions

Marc-André Lureau marcandre.lureau at gmail.com
Tue Jul 11 23:54:21 UTC 2017


Hi

On Mon, Jul 10, 2017 at 1:14 PM Peter Krempa <pkrempa at redhat.com> wrote:

> On Wed, Jul 05, 2017 at 12:58:51 +0100, Daniel Berrange wrote:
> > Currently all mockable functions are annotated with the 'noinline'
> > attribute. This is insufficient to guarantee that a function can
> > be reliably mocked with an LD_PRELOAD. The C language spec allows
> > the compiler to assume there is only a single implementation of
> > each function. It can thus do things like propagating constant
> > return values into the caller at compile time, or creating
> > multiple specialized copies of the function body each optimized
> > for a different caller. To prevent these optimizations we must
> > also set the 'noclone' and 'weak' attributes.
> >
> > This fixes the test suite when libvirt.so is built with CLang
> > with optimization enabled.
> >
> > Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
>

This patch makes virtlogd crash:

 (gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x00005555555a8084 in virHashCreateFull (size=size at entry=5,
dataFree=0x5555555b0930 <virObjectFreeHashData>,
keyCode=keyCode at entry=0x5555555a7c30
<virHashStrCode>, keyEqual=keyEqual at entry=0x5555555a7c10 <virHashStrEqual>,
keyCopy=keyCopy at entry=0x5555555a7bb0 <virHashStrCopy>,
keyFree=keyFree at entry=0x5555555a7b90
<virHashStrFree>) at util/virhash.c:167
#2  0x00005555555a8151 in virHashCreate (size=size at entry=5,
dataFree=<optimized out>) at util/virhash.c:196
#3  0x00005555555779f0 in virNetDaemonNew () at rpc/virnetdaemon.c:137
#4  0x00005555555708ec in virLogDaemonNew (privileged=false,
config=0x555555820940) at logging/log_daemon.c:163
#5  main (argc=<optimized out>, argv=0x7fffffffd888) at
logging/log_daemon.c:1069

any idea?

> ---
> >  build-aux/mock-noinline.pl      |  2 +-
> >  src/check-symfile.pl            |  2 +-
> >  src/internal.h                  | 23 ++++++++++++++++++-----
> >  src/qemu/qemu_capspriv.h        |  2 +-
> >  src/rpc/virnetsocket.h          |  4 ++--
> >  src/util/vircommand.h           |  2 +-
> >  src/util/vircrypto.h            |  2 +-
> >  src/util/virfile.h              |  2 +-
> >  src/util/virhostcpu.h           |  4 ++--
> >  src/util/virmacaddr.h           |  2 +-
> >  src/util/virnetdev.h            |  8 ++++----
> >  src/util/virnetdevip.h          |  2 +-
> >  src/util/virnetdevopenvswitch.h |  2 +-
> >  src/util/virnetdevtap.h         |  6 +++---
> >  src/util/virnuma.h              | 16 ++++++++--------
> >  src/util/virrandom.h            |  6 +++---
> >  src/util/virscsi.h              |  2 +-
> >  src/util/virscsivhost.h         |  2 +-
> >  src/util/virtpm.h               |  2 +-
> >  src/util/virutil.h              | 10 +++++-----
> >  src/util/viruuid.h              |  2 +-
> >  21 files changed, 58 insertions(+), 45 deletions(-)
>
> ACK
> --
> libvir-list mailing list
> libvir-list at redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list

-- 
Marc-André Lureau
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20170711/72e1e70f/attachment-0001.htm>


More information about the libvir-list mailing list