jceel / py-libzfs

Python libzfs bindings
16 stars 8 forks source link

Segmentation fault on using unexisting key #2

Closed mexicarne closed 9 years ago

mexicarne commented 9 years ago

It's easy to reproduce:

>>> import nvpair
>>> nvpair.NVList(0).keys()
[]
>>> nvpair.NVList(1).keys()
Segmentation fault (core dumped)

I'm using latest port version in FreeBSD (github tag c0100ab)

jceel commented 9 years ago

Well, NVList constructor is defined as follows:

def __init__(self, uintptr_t nvlist=0, otherdict=None):

so you are trying to access NVList located at 0x1. Segfault is obvious in that case :) What we are going to do is to hide nvpair implementation completely and make libzfs routines accept pure Python dicts. It will be cleaner and make it harder to shoot yourself in the foot.

mexicarne commented 9 years ago

Yep, I wasn't sure what I'm trying to accomplish, but since I was able to trigger segfault, I decided to report it for the case.

jceel commented 9 years ago

This should be fixed now - NVList is gone! Now all py-libzfs methods accept plain dicts instead :)

mexicarne commented 9 years ago

Great, thank you!