dcantrell / pyparted

Python bindings for GNU parted (libparted)
GNU General Public License v2.0
85 stars 42 forks source link

pyparted crashes in disk.destroy() #62

Open rlaager opened 5 years ago

rlaager commented 5 years ago
$ sudo python3
Python 3.6.7 (default, Oct 22 2018, 11:32:17) 
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import parted
>>> device = parted.getDevice("/path/to/disk.img")
>>> disk = parted.Disk(device)
>>> disk.destroy()
Backtrace has 20 calls on stack:
  20: /lib/x86_64-linux-gnu/libparted.so.2(ped_assert+0x45) [0x7f95f6dde6e5]
  19: /lib/x86_64-linux-gnu/libparted.so.2(ped_disk_commit_to_os+0) [0x7f95f6de1500]
  18: /usr/lib/python3/dist-packages/_ped.cpython-36m-x86_64-linux-gnu.so(_ped_Disk_dealloc+0x12) [0x7f95f7032742]
  17: python3() [0x564dc8]
  16: python3() [0x502fd8]
  15: python3(_PyEval_EvalFrameDefault+0x449) [0x506859]
  14: python3() [0x504c28]
  13: python3() [0x58650d]
  12: python3(PyObject_Call+0x3e) [0x59ebbe]
  11: python3(_PyEval_EvalFrameDefault+0x1807) [0x507c17]
  10: python3() [0x504c28]
  9: python3() [0x502540]
  8: python3() [0x502f3d]
  7: python3(_PyEval_EvalFrameDefault+0x449) [0x506859]
  6: python3() [0x504c28]
  5: python3(PyEval_EvalCode+0x23) [0x506393]
  4: python3() [0x634d52]
  3: python3() [0x4a38c5]
  2: python3(PyRun_InteractiveLoopFlags+0xd4) [0x4a5cd5]
  1: python3(PyRun_AnyFileExFlags+0x53) [0x6387b3]
Aborted

Sometimes it doesn't crash immediately, but calling disk.destroy() twice will guarantee a crash. From what I can tell, disk.destroy() (or at least _ped_Disk_dealloc()) is being called when the Python object is garbage-collected. If it was already called explicitly earlier, then it crashes.

rlaager commented 5 years ago

This also seems to happen with device.destroy().

rlaager commented 5 years ago

This is with pyparted 3.11.1-1ubuntu2 on Ubuntu 18.04.

dcantrell commented 5 years ago

Are you able to recreate this with the latest release, which is 3.11.2?

rlaager commented 5 years ago

I’m on vacation. I will retest when I get home and let you know.

rlaager commented 4 years ago

This is reproducible with master, specifically 22d2a2db35478b383e4313b87054e8e3d36482fa.