[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

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





On Wed, Jul 12, 2017 at 1:54 AM Marc-André Lureau <marcandre lureau gmail com> wrote:
Hi

On Mon, Jul 10, 2017 at 1:14 PM Peter Krempa <pkrempa 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 redhat com>

This patch makes virtlogd crash:

 (gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x00005555555a8084 in virHashCreateFull (size=size entry=5, dataFree=0x5555555b0930 <virObjectFreeHashData>, keyCode=keyCode entry=0x5555555a7c30 <virHashStrCode>, keyEqual=keyEqual entry=0x5555555a7c10 <virHashStrEqual>, keyCopy=keyCopy entry=0x5555555a7bb0 <virHashStrCopy>, keyFree=keyFree entry=0x5555555a7b90 <virHashStrFree>) at util/virhash.c:167
#2  0x00005555555a8151 in virHashCreate (size=size 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?


(btw, this is on f25,  gcc (GCC) 6.3.1 20161221 (Red Hat 6.3.1-1))

> ---
>  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 redhat com
https://www.redhat.com/mailman/listinfo/libvir-list
--
Marc-André Lureau
--
Marc-André Lureau

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]