Skip to content

Conversation

mmuman
Copy link
Contributor

@mmuman mmuman commented Jan 13, 2020

(This is a work in progress, open for comments…)

This allows to overlay bad sectors according to the mapfile generated by
ddrescue, to then see where sectors are used using fsck and trying to
copy files around.

This allows to overlay bad sectors according to the mapfile generated by
ddrescue, to then see where sectors are used using fsck and trying to
copy files around.
@mmuman mmuman closed this Jan 13, 2020
rwmjones added a commit to rwmjones/nbdkit that referenced this pull request Aug 17, 2020
A frequent cause of crashes on shutdown happens when the quit signal
has been received and the main thread and other threads race each
other at shutdown.  As in the typical stack trace below what happens
is that the main thread unloads the plugins while they are still being
used by one of the connection threads, causing the connection thread
to segfault after calling dlclosed functions.

To avoid this simply count the number of connection threads we create,
and at exit in the main thread wait until this count drops to 0 before
we actually start unloading anything.

  Thread 2 (Thread 0x7f8fb054ea40 (LWP 3105233)):
  #0  _asn1_set_down (down=0x5633dd26c010, node=0x5633dd26be70) at parser_aux.h:116
  libguestfs#1  asn1_delete_structure2 (structure=structure@entry=0x7f8fb0dd3fa0 <_gnutls_pkix1_asn>, flags=flags@entry=0) at structure.c:328
  libguestfs#2  0x00007f8fb06e702b in asn1_delete_structure (structure=structure@entry=0x7f8fb0dd3fa0 <_gnutls_pkix1_asn>) at structure.c:293
  libguestfs#3  0x00007f8fb0c66544 in _gnutls_global_deinit (destructor=1) at global.c:419
  libguestfs#4  0x00007f8fb0e0d13b in _dl_fini () at dl-fini.c:138
  libguestfs#5  0x00007f8fb0a0ae87 in __run_exit_handlers (status=0, listp=0x7f8fb0b8e578 <__exit_funcs>, run_list_atexit=run_list_atexit@entry=true, run_dtors=run_dtors@entry=true) at exit.c:108
  libguestfs#6  0x00007f8fb0a0b040 in __GI_exit (status=<optimized out>) at exit.c:139
  libguestfs#7  0x00005633d47626ee in main (argc=<optimized out>, argv=0x7ffecd6115d8) at main.c:705

  Thread 1 (Thread 0x7f8fb054d700 (LWP 3105257)):
  #0  backend_finalize (b=<optimized out>, conn=conn@entry=0x5633dd287c40) at backend.c:227
  libguestfs#1  0x00005633d476579f in handle_single_connection (sockin=<optimized out>, sockout=<optimized out>) at connections.c:222
  libguestfs#2  0x00005633d476e9e9 in start_thread (datav=0x5633dd269620) at sockets.c:351
  libguestfs#3  0x00007f8fb0b9e4e2 in start_thread (arg=<optimized out>) at pthread_create.c:479
  libguestfs#4  0x00007f8fb0acd643 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
libguestfs pushed a commit that referenced this pull request Aug 15, 2021
The zstd allocator crashed when asked to either fill or zero space
that had previously been unallocated.  This adds a check for this
case.

  $ rpm -q nbdkit
  nbdkit-1.27.4-1.fc35.x86_64
  $ nbdkit data "0*10" allocator=zstd -fv
  nbdkit: debug: nbdkit 1.27.4 (nbdkit-1.27.4-1.fc35)
  nbdkit: debug: TLS disabled: could not load TLS certificates
  nbdkit: debug: registering plugin /usr/lib64/nbdkit/plugins/nbdkit-data-plugin.so
  nbdkit: debug: registered plugin /usr/lib64/nbdkit/plugins/nbdkit-data-plugin.so (name data)
  nbdkit: debug: data: load
  nbdkit: debug: data: config key=data, value=0*10
  nbdkit: debug: data: config key=allocator, value=zstd
  nbdkit: debug: data: config_complete
  nbdkit: debug: using thread model: parallel
  nbdkit: debug: data: get_ready
  nbdkit: debug: allocator: zstd
  Segmentation fault (core dumped)

  (gdb) bt
  #0  0x00007ff61d67284e in zstd_array_zero (a=0x557b37763b50, count=10,
      offset=0) at ../../common/allocators/zstd.c:484
  #1  0x00007ff61d672aab in zstd_array_fill (a=0x557b37763b50,
      c=<optimized out>, count=10, offset=0)
      at ../../common/allocators/zstd.c:432
  #2  0x00007ff61d6703c2 in evaluate (dict=0x0, root=<optimized out>,
      a=0x557b37763b50, offset=0x7fff9a6b5330, size=0x7fff9a6b5310)
      at /usr/src/debug/nbdkit-1.27.4-1.fc35.x86_64/plugins/data/format.c:1346
  #3  0x00007ff61d670663 in read_data_format (size_rtn=0x7fff9a6b5310,
      a=0x557b37763b50, value=<optimized out>)
      at /usr/src/debug/nbdkit-1.27.4-1.fc35.x86_64/plugins/data/format.c:314
  #4  data_get_ready ()
      at /usr/src/debug/nbdkit-1.27.4-1.fc35.x86_64/plugins/data/data.c:214
  #5  0x0000557b2e5a005f in plugin_get_ready (b=0x557b37763870)
      at /usr/src/debug/nbdkit-1.27.4-1.fc35.x86_64/server/plugins.c:259
  #6  0x0000557b2e59a073 in main (argc=<optimized out>, argv=<optimized out>)
      at /usr/src/debug/nbdkit-1.27.4-1.fc35.x86_64/server/main.c:731
libguestfs pushed a commit that referenced this pull request Aug 16, 2021
The zstd allocator crashed when asked to either fill or zero space
that had previously been unallocated.  This adds a check for this
case.

  $ rpm -q nbdkit
  nbdkit-1.27.4-1.fc35.x86_64
  $ nbdkit data "0*10" allocator=zstd -fv
  nbdkit: debug: nbdkit 1.27.4 (nbdkit-1.27.4-1.fc35)
  nbdkit: debug: TLS disabled: could not load TLS certificates
  nbdkit: debug: registering plugin /usr/lib64/nbdkit/plugins/nbdkit-data-plugin.so
  nbdkit: debug: registered plugin /usr/lib64/nbdkit/plugins/nbdkit-data-plugin.so (name data)
  nbdkit: debug: data: load
  nbdkit: debug: data: config key=data, value=0*10
  nbdkit: debug: data: config key=allocator, value=zstd
  nbdkit: debug: data: config_complete
  nbdkit: debug: using thread model: parallel
  nbdkit: debug: data: get_ready
  nbdkit: debug: allocator: zstd
  Segmentation fault (core dumped)

  (gdb) bt
  #0  0x00007ff61d67284e in zstd_array_zero (a=0x557b37763b50, count=10,
      offset=0) at ../../common/allocators/zstd.c:484
  #1  0x00007ff61d672aab in zstd_array_fill (a=0x557b37763b50,
      c=<optimized out>, count=10, offset=0)
      at ../../common/allocators/zstd.c:432
  #2  0x00007ff61d6703c2 in evaluate (dict=0x0, root=<optimized out>,
      a=0x557b37763b50, offset=0x7fff9a6b5330, size=0x7fff9a6b5310)
      at /usr/src/debug/nbdkit-1.27.4-1.fc35.x86_64/plugins/data/format.c:1346
  #3  0x00007ff61d670663 in read_data_format (size_rtn=0x7fff9a6b5310,
      a=0x557b37763b50, value=<optimized out>)
      at /usr/src/debug/nbdkit-1.27.4-1.fc35.x86_64/plugins/data/format.c:314
  #4  data_get_ready ()
      at /usr/src/debug/nbdkit-1.27.4-1.fc35.x86_64/plugins/data/data.c:214
  #5  0x0000557b2e5a005f in plugin_get_ready (b=0x557b37763870)
      at /usr/src/debug/nbdkit-1.27.4-1.fc35.x86_64/server/plugins.c:259
  #6  0x0000557b2e59a073 in main (argc=<optimized out>, argv=<optimized out>)
      at /usr/src/debug/nbdkit-1.27.4-1.fc35.x86_64/server/main.c:731

(cherry picked from commit 712fd7b)
libguestfs pushed a commit that referenced this pull request Oct 21, 2021
VDDK 7.0.0 and 7.0.3 crash with GLIBC_TUNABLES (malloc debugging) and
latest glibc.  This likely indicates a bug in VDDK, but as we cannot
fix it we need to disable the extra hygiene checks instead.  For
information the stack trace is below.

  Program terminated with signal SIGSEGV, Segmentation fault.
  #0  malloc_check_get_size (mem=0x0)
      at /usr/src/debug/glibc-2.34.9000-13.fc36.x86_64/malloc/malloc-check.c:39
  39	  magic = (((uintptr_t) p >> 3) ^ ((uintptr_t) p >> 11)) & 0xFF;
  [Current thread is 1 (Thread 0x7fea8056b640 (LWP 3905172))]
  (gdb) bt
  #0  malloc_check_get_size (mem=0x0)
      at /usr/src/debug/glibc-2.34.9000-13.fc36.x86_64/malloc/malloc-check.c:39
  #1  malloc_usable_size (mem=0x0) at malloc-debug.c:405
  #2  0x00007fea7fd5199b in greedy_realloc0 (p=p@entry=0x7fea805690c0,
      need=need@entry=2, size=size@entry=16) at ../src/basic/alloc-util.c:87
  #3  0x00007fea7fd51b13 in netlink_container_parse (m=m@entry=0x555d34e77f80,
      container=0x555d34e77f90, rta=0x555d34e821f8, rt_len=<optimized out>)
      at ../src/libsystemd/sd-netlink/netlink-message.c:1078
  #4  0x00007fea7fd557ec in sd_netlink_message_rewind (genl=<optimized out>,
      m=<optimized out>) at ../src/libsystemd/sd-netlink/netlink-message.c:1324
  #5  socket_read_message (rtnl=<optimized out>)
      at ../src/libsystemd/sd-netlink/netlink-socket.c:375
  #6  sd_netlink_read (usec=0, ret=0x7fea805692a0, serial=<optimized out>,
      rtnl=<optimized out>) at ../src/libsystemd/sd-netlink/sd-netlink.c:700
  #7  sd_netlink_call (rtnl=<optimized out>, message=<optimized out>,
      ret=0x7fea805692a0, usec=0)
      at ../src/libsystemd/sd-netlink/sd-netlink.c:743
  #8  0x00007fea7fd5818e in local_addresses (af=2, ret=0x7fea80569378,
      ifindex=0, context=0x0) at ../src/shared/local-addresses.c:90
  #9  0x00007fea7fd590b9 in _nss_myhostname_gethostbyname3_r (
      name=<optimized out>, af=<optimized out>, host=0x7fea805695a0,
      buffer=0x7fea80569750 "\177", buflen=1024, errnop=0x7fea8056b4b8,
      h_errnop=0x7fea80569594, ttlp=0x0, canonp=0x0)
      at ../src/nss-myhostname/nss-myhostname.c:373
  #10 0x00007fea7fd593cb in _nss_myhostname_gethostbyname_r (
      name=0x7fea80569601 "pick", host=0x7fea805695a0,
      buffer=0x7fea80569750 "\177", buflen=1024, errnop=0x7fea8056b4b8,
      h_errnop=0x7fea80569594) at ../src/nss-myhostname/nss-myhostname.c:514
  #11 0x00007fea864491cb in __gethostbyname_r (
      name=0x7fea80569601 "pick", resbuf=0x7fea805695a0,
      buffer=<optimized out>, buflen=1024, result=<optimized out>,
      h_errnop=0x7fea80569594) at ../nss/getXXbyYY_r.c:273
  #12 0x00007fea85bdcca4 in ?? ()
     from vddk-7.0.3/vmware-vix-disklib-distrib/lib64/libvixDiskLib.so.7
  #13 0x00007fea85bd2bb2 in ?? ()
     from vddk-7.0.3/vmware-vix-disklib-distrib/lib64/libvixDiskLib.so.7
  #14 0x00007fea85bba567 in ?? ()
     from vddk-7.0.3/vmware-vix-disklib-distrib/lib64/libvixDiskLib.so.7
  #15 0x00007fea85bbab75 in ?? ()
     from vddk-7.0.3/vmware-vix-disklib-distrib/lib64/libvixDiskLib.so.7
  #16 0x00007fea85bc63bd in ?? ()
     from vddk-7.0.3/vmware-vix-disklib-distrib/lib64/libvixDiskLib.so.7
  #17 0x00007fea85bc42ec in ?? ()
     from vddk-7.0.3/vmware-vix-disklib-distrib/lib64/libvixDiskLib.so.7
  #18 0x00007fea85bbf026 in ?? ()
     from vddk-7.0.3/vmware-vix-disklib-distrib/lib64/libvixDiskLib.so.7
  #19 0x00007fea85bc0038 in ?? ()
     from vddk-7.0.3/vmware-vix-disklib-distrib/lib64/libvixDiskLib.so.7
  #20 0x00007fea85c2fb23 in ?? ()
     from vddk-7.0.3/vmware-vix-disklib-distrib/lib64/libvixDiskLib.so.7
  #21 0x00007fea85c2f160 in ?? ()
     from vddk-7.0.3/vmware-vix-disklib-distrib/lib64/libvixDiskLib.so.7
  #22 0x00007fea85c2f1ba in ?? ()
     from vddk-7.0.3/vmware-vix-disklib-distrib/lib64/libvixDiskLib.so.7
  #23 0x00007fea85d0c0b9 in ?? ()
     from vddk-7.0.3/vmware-vix-disklib-distrib/lib64/libvixDiskLib.so.7
  #24 0x00007fea85d079cb in ?? ()
     from vddk-7.0.3/vmware-vix-disklib-distrib/lib64/libvixDiskLib.so.7
  #25 0x00007fea85cb2831 in ?? ()
     from vddk-7.0.3/vmware-vix-disklib-distrib/lib64/libvixDiskLib.so.7
  #26 0x00007fea85ca4702 in ?? ()
     from vddk-7.0.3/vmware-vix-disklib-distrib/lib64/libvixDiskLib.so.7
  #27 0x00007fea85c9f76f in ?? ()
     from vddk-7.0.3/vmware-vix-disklib-distrib/lib64/libvixDiskLib.so.7
  #28 0x00007fea85c7b59f in ?? ()
     from vddk-7.0.3/vmware-vix-disklib-distrib/lib64/libvixDiskLib.so.7
  #29 0x00007fea85c7c11d in ?? ()
     from vddk-7.0.3/vmware-vix-disklib-distrib/lib64/libvixDiskLib.so.7
  #30 0x00007fea85bb4475 in ?? ()
     from vddk-7.0.3/vmware-vix-disklib-distrib/lib64/libvixDiskLib.so.7
  #31 0x00007fea85bb4717 in VixDiskLib_Open ()
     from vddk-7.0.3/vmware-vix-disklib-distrib/lib64/libvixDiskLib.so.7
  #32 0x00007fea867b0dbb in vddk_open (readonly=<optimized out>)
      at /home/rjones/d/nbdkit/plugins/vddk/vddk.c:717
  #33 0x0000555d2a83d922 in plugin_open (c=0x555d34e81d10, readonly=0,
      exportname=<optimized out>, is_tls=<optimized out>)
      at /home/rjones/d/nbdkit/server/plugins.c:353
  #34 0x0000555d2a83572d in backend_open (b=0x555d34668db0, readonly=0,
      exportname=0x555d34dae020 "", shared=0)
      at /home/rjones/d/nbdkit/server/backend.c:292
  #35 0x0000555d2a83b937 in protocol_common_open (
      exportsize=exportsize@entry=0x7fea8056a9e0,
      flags=flags@entry=0x555d34e7f604,
      exportname=exportname@entry=0x555d34e7eeb0 "")
      at /home/rjones/d/nbdkit/server/protocol-handshake.c:83
  #36 0x0000555d2a83e140 in finish_newstyle_options (exportsize=0x7fea8056a9e0,
      exportname_in=<optimized out>, exportnamelen=<optimized out>)
      at /home/rjones/d/nbdkit/server/protocol-handshake-newstyle.c:284
  #37 0x0000555d2a837ee0 in negotiate_handshake_newstyle_options ()
      at /home/rjones/d/nbdkit/server/protocol-handshake-newstyle.c:572
  #38 protocol_handshake_newstyle ()
      at /home/rjones/d/nbdkit/server/protocol-handshake-newstyle.c:904
  #39 protocol_handshake ()
      at /home/rjones/d/nbdkit/server/protocol-handshake.c:55
  #40 handle_single_connection (sockin=<optimized out>, sockout=<optimized out>)
      at /home/rjones/d/nbdkit/server/connections.c:171
  #41 0x0000555d2a83e4e0 in start_thread (datav=0x555d34d987d0)
      at /home/rjones/d/nbdkit/server/sockets.c:354
  #42 0x00007fea863b4677 in start_thread (arg=<optimized out>)
      at pthread_create.c:434
  #43 0x00007fea86439320 in clone3 ()
      at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
libguestfs pushed a commit that referenced this pull request Oct 25, 2021
VDDK 7.0.0 and 7.0.3 crash with GLIBC_TUNABLES (malloc debugging) and
latest glibc.  This likely indicates a bug in VDDK, but as we cannot
fix it we need to disable the extra hygiene checks instead.  For
information the stack trace is below.

  Program terminated with signal SIGSEGV, Segmentation fault.
  #0  malloc_check_get_size (mem=0x0)
      at /usr/src/debug/glibc-2.34.9000-13.fc36.x86_64/malloc/malloc-check.c:39
  39	  magic = (((uintptr_t) p >> 3) ^ ((uintptr_t) p >> 11)) & 0xFF;
  [Current thread is 1 (Thread 0x7fea8056b640 (LWP 3905172))]
  (gdb) bt
  #0  malloc_check_get_size (mem=0x0)
      at /usr/src/debug/glibc-2.34.9000-13.fc36.x86_64/malloc/malloc-check.c:39
  #1  malloc_usable_size (mem=0x0) at malloc-debug.c:405
  #2  0x00007fea7fd5199b in greedy_realloc0 (p=p@entry=0x7fea805690c0,
      need=need@entry=2, size=size@entry=16) at ../src/basic/alloc-util.c:87
  #3  0x00007fea7fd51b13 in netlink_container_parse (m=m@entry=0x555d34e77f80,
      container=0x555d34e77f90, rta=0x555d34e821f8, rt_len=<optimized out>)
      at ../src/libsystemd/sd-netlink/netlink-message.c:1078
  #4  0x00007fea7fd557ec in sd_netlink_message_rewind (genl=<optimized out>,
      m=<optimized out>) at ../src/libsystemd/sd-netlink/netlink-message.c:1324
  #5  socket_read_message (rtnl=<optimized out>)
      at ../src/libsystemd/sd-netlink/netlink-socket.c:375
  #6  sd_netlink_read (usec=0, ret=0x7fea805692a0, serial=<optimized out>,
      rtnl=<optimized out>) at ../src/libsystemd/sd-netlink/sd-netlink.c:700
  #7  sd_netlink_call (rtnl=<optimized out>, message=<optimized out>,
      ret=0x7fea805692a0, usec=0)
      at ../src/libsystemd/sd-netlink/sd-netlink.c:743
  #8  0x00007fea7fd5818e in local_addresses (af=2, ret=0x7fea80569378,
      ifindex=0, context=0x0) at ../src/shared/local-addresses.c:90
  #9  0x00007fea7fd590b9 in _nss_myhostname_gethostbyname3_r (
      name=<optimized out>, af=<optimized out>, host=0x7fea805695a0,
      buffer=0x7fea80569750 "\177", buflen=1024, errnop=0x7fea8056b4b8,
      h_errnop=0x7fea80569594, ttlp=0x0, canonp=0x0)
      at ../src/nss-myhostname/nss-myhostname.c:373
  #10 0x00007fea7fd593cb in _nss_myhostname_gethostbyname_r (
      name=0x7fea80569601 "pick", host=0x7fea805695a0,
      buffer=0x7fea80569750 "\177", buflen=1024, errnop=0x7fea8056b4b8,
      h_errnop=0x7fea80569594) at ../src/nss-myhostname/nss-myhostname.c:514
  #11 0x00007fea864491cb in __gethostbyname_r (
      name=0x7fea80569601 "pick", resbuf=0x7fea805695a0,
      buffer=<optimized out>, buflen=1024, result=<optimized out>,
      h_errnop=0x7fea80569594) at ../nss/getXXbyYY_r.c:273
  #12 0x00007fea85bdcca4 in ?? ()
     from vddk-7.0.3/vmware-vix-disklib-distrib/lib64/libvixDiskLib.so.7
  #13 0x00007fea85bd2bb2 in ?? ()
     from vddk-7.0.3/vmware-vix-disklib-distrib/lib64/libvixDiskLib.so.7
  #14 0x00007fea85bba567 in ?? ()
     from vddk-7.0.3/vmware-vix-disklib-distrib/lib64/libvixDiskLib.so.7
  #15 0x00007fea85bbab75 in ?? ()
     from vddk-7.0.3/vmware-vix-disklib-distrib/lib64/libvixDiskLib.so.7
  #16 0x00007fea85bc63bd in ?? ()
     from vddk-7.0.3/vmware-vix-disklib-distrib/lib64/libvixDiskLib.so.7
  #17 0x00007fea85bc42ec in ?? ()
     from vddk-7.0.3/vmware-vix-disklib-distrib/lib64/libvixDiskLib.so.7
  #18 0x00007fea85bbf026 in ?? ()
     from vddk-7.0.3/vmware-vix-disklib-distrib/lib64/libvixDiskLib.so.7
  #19 0x00007fea85bc0038 in ?? ()
     from vddk-7.0.3/vmware-vix-disklib-distrib/lib64/libvixDiskLib.so.7
  #20 0x00007fea85c2fb23 in ?? ()
     from vddk-7.0.3/vmware-vix-disklib-distrib/lib64/libvixDiskLib.so.7
  #21 0x00007fea85c2f160 in ?? ()
     from vddk-7.0.3/vmware-vix-disklib-distrib/lib64/libvixDiskLib.so.7
  #22 0x00007fea85c2f1ba in ?? ()
     from vddk-7.0.3/vmware-vix-disklib-distrib/lib64/libvixDiskLib.so.7
  #23 0x00007fea85d0c0b9 in ?? ()
     from vddk-7.0.3/vmware-vix-disklib-distrib/lib64/libvixDiskLib.so.7
  #24 0x00007fea85d079cb in ?? ()
     from vddk-7.0.3/vmware-vix-disklib-distrib/lib64/libvixDiskLib.so.7
  #25 0x00007fea85cb2831 in ?? ()
     from vddk-7.0.3/vmware-vix-disklib-distrib/lib64/libvixDiskLib.so.7
  #26 0x00007fea85ca4702 in ?? ()
     from vddk-7.0.3/vmware-vix-disklib-distrib/lib64/libvixDiskLib.so.7
  #27 0x00007fea85c9f76f in ?? ()
     from vddk-7.0.3/vmware-vix-disklib-distrib/lib64/libvixDiskLib.so.7
  #28 0x00007fea85c7b59f in ?? ()
     from vddk-7.0.3/vmware-vix-disklib-distrib/lib64/libvixDiskLib.so.7
  #29 0x00007fea85c7c11d in ?? ()
     from vddk-7.0.3/vmware-vix-disklib-distrib/lib64/libvixDiskLib.so.7
  #30 0x00007fea85bb4475 in ?? ()
     from vddk-7.0.3/vmware-vix-disklib-distrib/lib64/libvixDiskLib.so.7
  #31 0x00007fea85bb4717 in VixDiskLib_Open ()
     from vddk-7.0.3/vmware-vix-disklib-distrib/lib64/libvixDiskLib.so.7
  #32 0x00007fea867b0dbb in vddk_open (readonly=<optimized out>)
      at /home/rjones/d/nbdkit/plugins/vddk/vddk.c:717
  #33 0x0000555d2a83d922 in plugin_open (c=0x555d34e81d10, readonly=0,
      exportname=<optimized out>, is_tls=<optimized out>)
      at /home/rjones/d/nbdkit/server/plugins.c:353
  #34 0x0000555d2a83572d in backend_open (b=0x555d34668db0, readonly=0,
      exportname=0x555d34dae020 "", shared=0)
      at /home/rjones/d/nbdkit/server/backend.c:292
  #35 0x0000555d2a83b937 in protocol_common_open (
      exportsize=exportsize@entry=0x7fea8056a9e0,
      flags=flags@entry=0x555d34e7f604,
      exportname=exportname@entry=0x555d34e7eeb0 "")
      at /home/rjones/d/nbdkit/server/protocol-handshake.c:83
  #36 0x0000555d2a83e140 in finish_newstyle_options (exportsize=0x7fea8056a9e0,
      exportname_in=<optimized out>, exportnamelen=<optimized out>)
      at /home/rjones/d/nbdkit/server/protocol-handshake-newstyle.c:284
  #37 0x0000555d2a837ee0 in negotiate_handshake_newstyle_options ()
      at /home/rjones/d/nbdkit/server/protocol-handshake-newstyle.c:572
  #38 protocol_handshake_newstyle ()
      at /home/rjones/d/nbdkit/server/protocol-handshake-newstyle.c:904
  #39 protocol_handshake ()
      at /home/rjones/d/nbdkit/server/protocol-handshake.c:55
  #40 handle_single_connection (sockin=<optimized out>, sockout=<optimized out>)
      at /home/rjones/d/nbdkit/server/connections.c:171
  #41 0x0000555d2a83e4e0 in start_thread (datav=0x555d34d987d0)
      at /home/rjones/d/nbdkit/server/sockets.c:354
  #42 0x00007fea863b4677 in start_thread (arg=<optimized out>)
      at pthread_create.c:434
  #43 0x00007fea86439320 in clone3 ()
      at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81

(cherry picked from commit 03406a7)
libguestfs pushed a commit that referenced this pull request Aug 12, 2022
  #0  __GI___libc_realloc (oldmem=0x40, bytes=bytes@entry=16) at malloc.c:3425
  #1  0x00007fedb6bcf34d in __GI___getdelim (
      lineptr=lineptr@entry=0x7fffd4d33b38, n=n@entry=0x7fffd4d33b30,
      delimiter=delimiter@entry=10, fp=fp@entry=0x55b5f0c166b0)
      at iogetdelim.c:102
  #2  0x000055b5ef79a50b in getline (__stream=0x55b5f0c166b0,
      __n=0x7fffd4d33b30, __lineptr=0x7fffd4d33b38)
      at /usr/include/bits/stdio.h:120
  #3  run_test () at /home/rjones/d/nbdkit/tests/test-exit-with-parent.c:185
  #4  main (argc=<optimized out>, argv=<optimized out>)
      at /home/rjones/d/nbdkit/tests/test-exit-with-parent.c:66

pidstr (passed by reference to getline) was uninitialized.  However
this code path was never called at all because of an incorrect test of
the exit status of the subprocess fixed in the following commit.
shasheene pushed a commit to rescuezilla/nbdkit that referenced this pull request Aug 1, 2025
Valgrind works ... but it takes several minutes to run, making the
whole 'make check-valgrind' very slow.

I collected a stack trace from vgdb (valgrind gdb) during the long
delay to confirm the specific function:

  Thread 2 received signal SIGTRAP, Trace/breakpoint trap.
  [Switching to Thread 1050375]
  _nettle_write_be32 (length=<optimized out>,
      dst=0xdf3d250 "\312hu\256\301\260\230b\250'\362\3764\nr\373\a\004\005\002\003", src=0xdf3d410) at /usr/src/debug/nettle-3.9.1-6.fc40.x86_64/write-be32.c:54
  Downloading source file /usr/src/debug/nettle-3.9.1-6.fc40.x86_64/write-be32.c
  54          WRITE_UINT32(dst, src[i]);
  (gdb) bt
  #0  _nettle_write_be32 (length=<optimized out>,
      dst=0xdf3d250 "\312hu\256\301\260\230b\250'\362\3764\nr\373\a\004\005\002\003", src=0xdf3d410) at /usr/src/debug/nettle-3.9.1-6.fc40.x86_64/write-be32.c:54
  libguestfs#1  0x000000000d176425 in nettle_sha256_digest (ctx=0xdf3d410,
      length=<optimized out>, digest=<optimized out>)
      at /usr/src/debug/nettle-3.9.1-6.fc40.x86_64/sha256.c:153
  libguestfs#2  0x000000000d16fae7 in nettle_hmac_digest (outer=0xdf3d330,
      inner=0xdf3d3a0, state=0xdf3d410, hash=0xd1a5240 <nettle_sha256>,
      length=32,
      dst=0xdf3d240 "q\bp\260@8Mt\225$\234\217\243\312hu\256\301\260\230b\250'\362\3764\nr\373\a\004\005\002\003")
      at /usr/src/debug/nettle-3.9.1-6.fc40.x86_64/hmac.c:112
  libguestfs#3  0x000000000d173e3f in nettle_pbkdf2 (mac_ctx=mac_ctx@entry=0xdf3d330,
      update=0xd1765c0 <nettle_hmac_sha256_update>, digest=<optimized out>,
      digest_size=32, iterations=iterations@entry=13415458,
      salt_length=salt_length@entry=32, salt=<optimized out>, length=64,
      dst=0xd3b74c0 "") at /usr/src/debug/nettle-3.9.1-6.fc40.x86_64/pbkdf2.c:87
  libguestfs#4  0x000000000cb02b6e in wrap_nettle_pbkdf2 (mac=<optimized out>,
      key=0xd377420, keysize=6, salt=0xd378a98, saltsize=32,
      iter_count=13415458, output=0xd3b74c0, length=64)
      at ../../../lib/nettle/mac.c:905
  libguestfs#5  0x000000000ca16f68 in gnutls_pbkdf2 (mac=mac@entry=GNUTLS_MAC_SHA256,
      key=key@entry=0xdf3e680, salt=salt@entry=0xdf3e690, iter_count=13415458,
      output=output@entry=0xd3b74c0, length=length@entry=64)
      at ../../lib/crypto-api.c:2180
  libguestfs#6  0x000000000c993f83 in try_passphrase_in_keyslot (next=0xd378710,
      h=0xd3789c0, i=<optimized out>, passphrase=0xd377420 "123456")
      at /home/rjones/d/nbdkit/filters/luks/luks-encryption.c:614
  libguestfs#7  load_header (next=0xd378710, passphrase=0xd377420 "123456")
      at /home/rjones/d/nbdkit/filters/luks/luks-encryption.c:835
  libguestfs#8  luks_prepare (next=0xd378710, handle=0xd378970, readonly=<optimized out>)
      at /home/rjones/d/nbdkit/filters/luks/luks.c:140
  libguestfs#9  0x000000000011157d in filter_prepare (c=<optimized out>,
      readonly=<optimized out>) at /home/rjones/d/nbdkit/server/filters.c:342
  libguestfs#10 0x000000000011356b in backend_prepare (c=0xd378510)
      at /home/rjones/d/nbdkit/server/backend.c:332
  libguestfs#11 0x000000000011d40c in protocol_common_open (
      exportsize=exportsize@entry=0xdf3e938, flags=flags@entry=0xd37829c,
      exportname=exportname@entry=0xd3784c0 "")
      at /home/rjones/d/nbdkit/server/protocol-handshake.c:88
  libguestfs#12 0x000000000011d997 in finish_newstyle_options (
      exportsize=exportsize@entry=0xdf3e938,
      exportname_in=exportname_in@entry=0xd378474 "",
      exportnamelen=exportnamelen@entry=0)
      at /home/rjones/d/nbdkit/server/protocol-handshake-newstyle.c:319
  libguestfs#13 0x0000000000121e25 in negotiate_handshake_newstyle_options ()
      at /home/rjones/d/nbdkit/server/protocol-handshake-newstyle.c:619
  libguestfs#14 0x0000000000118c3e in protocol_handshake_newstyle ()
      at /home/rjones/d/nbdkit/server/protocol-handshake-newstyle.c:991
  libguestfs#15 protocol_handshake ()
      at /home/rjones/d/nbdkit/server/protocol-handshake.c:55
  libguestfs#16 handle_single_connection (sockin=<optimized out>, sockout=<optimized out>)
      at /home/rjones/d/nbdkit/server/connections.c:180
  libguestfs#17 0x000000000011caf1 in start_thread (datav=0xd377f00)
      at /home/rjones/d/nbdkit/server/sockets.c:377
  libguestfs#18 0x000000000ccad1a7 in start_thread (arg=<optimized out>)
      at pthread_create.c:447
  libguestfs#19 0x000000000cd2f174 in clone ()
shasheene pushed a commit to rescuezilla/nbdkit that referenced this pull request Aug 1, 2025
I observed this crash several times after adding new functionality to
nbdkit vddk --dump-plugin in the following commit, but this could
happen for existing tests if the machine was fast enough.

Thread 1 is the still-running background thread.  Notice that thread 2
is dlclosing dummy-vddk.

  Thread 2 (Thread 0x7fc0b8032a40 (LWP 181911)):
  #0  0x00007fc0b78c4fbc in __do_global_dtors_aux () from /lib64/libhogweed.so.6
  libguestfs#1  0x00007ffd1fe57ad0 in ?? ()
  libguestfs#2  0x00007fc0b81650f2 in _dl_call_fini (closure_map=0x7fc0b80db9f0) at dl-call_fini.c:43
  Backtrace stopped: frame did not save the PC

  Thread 1 (Thread 0x7fc0b76006c0 (LWP 181912)):
  #0  0x00007fc0b76ef2e0 in ?? ()
  libguestfs#1  0x00007fc0b7c7e797 in start_thread (arg=<optimized out>) at pthread_create.c:447
  libguestfs#2  0x00007fc0b7d0278c in __GI___clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant