Bug 1583805

Summary: vgcfgrestore segfaults if attempted with missing PV
Product: Red Hat Enterprise Linux 6 Reporter: Corey Marthaler <cmarthal>
Component: lvm2Assignee: LVM and device-mapper development team <lvm-team>
lvm2 sub component: Command-line tools (RHEL6) QA Contact: cluster-qe <cluster-qe>
Status: CLOSED WONTFIX Docs Contact:
Severity: medium    
Priority: unspecified CC: agk, cluster-qe, heinzm, jbrassow, lvm-team, mnavrati, msnitzer, prajnoha, prockai, rbednar, revers, rhandlin, teigland, thornber, zkabelac
Version: 6.9   
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1348327 Environment:
Last Closed: 2018-06-04 21:37:21 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1348327    
Bug Blocks:    

Comment 3 Corey Marthaler 2018-05-29 18:25:07 UTC
SCENARIO - [vgcfgrestore_mirror_with_missing_pv]
Create a mirror, force remove a leg, and then restore it's VG
mckinley-04: lvcreate  --type mirror -m 1 -n missing_pv_mirror -L 100M --nosync mirror_sanity
  WARNING: New mirror won't be synchronised. Don't read what you didn't write!
Deactivating missing_pv_mirror mirror
Backup the VG config
mckinley-04 vgcfgbackup -f /tmp/mirror_sanity.bkup.25530 mirror_sanity
Force removing PV /dev/mapper/mpathbp1 (used in this mirror)
mckinley-04: 'pvremove -ff --yes /dev/mapper/mpathbp1'
  WARNING: PV /dev/mapper/mpathbp1 belongs to Volume Group mirror_sanity (consider using vgreduce).
  WARNING: Wiping physical volume label from /dev/mapper/mpathbp1 of volume group "mirror_sanity"
Verifying that this VG is now corrupt
  WARNING: Device for PV LijBYU-jbu2-L4gF-fLib-rFFJ-yCaD-YhnUf4 not found or rejected by a filter.
  Failed to find physical volume "/dev/mapper/mpathbp1".
Attempt to restore the VG back to it's original state (should not segfault)
mckinley-04 vgcfgrestore -f /tmp/mirror_sanity.bkup.25530 mirror_sanity
  Couldn't find device with uuid LijBYU-jbu2-L4gF-fLib-rFFJ-yCaD-YhnUf4.
Checking syslog to see if vgcfgrestore segfaulted
vgcfgrestore segfaulted on mckinley-04



Core was generated by `vgcfgrestore -f /tmp/mirror_sanity.bkup.18353 mirror_sanity'.
Program terminated with signal 11, Segmentation fault.
#0  __strncpy_ssse3 () at ../sysdeps/x86_64/multiarch/strcpy.S:94
94              pcmpeqb (%rsi), %xmm0                   /* compare 16 bytes in (%rsi) and %xmm0 for equality, try to find null char*/
(gdb) 
(gdb) 
(gdb) bt
#0  __strncpy_ssse3 () at ../sysdeps/x86_64/multiarch/strcpy.S:94
#1  0x00005610d060fa6a in lvmcache_info_from_pvid (pvid=<value optimized out>, valid_only=0) at /usr/include/bits/string3.h:121
#2  0x00005610d062a5a8 in _restore_vg_should_write_pv (cmd=0x5610d0f91110, vg=0x5610d1d9b800, pp=0x0, drop_lvmetad=1) at format_text/archiver.c:342
#3  backup_restore_vg (cmd=0x5610d0f91110, vg=0x5610d1d9b800, pp=0x0, drop_lvmetad=1) at format_text/archiver.c:452
#4  0x00005610d062a8ca in backup_restore_from_file (cmd=0x5610d0f91110, vg_name=<value optimized out>, file=<value optimized out>, force=0) at format_text/archiver.c:534
#5  0x00005610d05fc9e9 in vgcfgrestore (cmd=0x5610d0f91110, argc=<value optimized out>, argv=<value optimized out>) at vgcfgrestore.c:63
#6  0x00005610d05e54e9 in lvm_run_command (cmd=0x5610d0f91110, argc=1, argv=0x7ffce7cff6b0) at lvmcmdline.c:1655
#7  0x00005610d05e9779 in lvm2_main (argc=4, argv=0x7ffce7cff698) at lvmcmdline.c:2121
#8  0x00007f39fd0d3d1d in __libc_start_main (main=0x5610d0606290 <main>, argc=4, ubp_av=0x7ffce7cff698, init=<value optimized out>, fini=<value optimized out>, rtld_fini=<value optimized out>, 
    stack_end=0x7ffce7cff688) at libc-start.c:226
#9  0x00005610d05ce299 in _start ()