Skip to content

lru-dict segfaults on use after being serialized/deserialized with pickle #17

Open
@zmjjmz

Description

@zmjjmz

It's always a bit weird to hit a segfault in Python!

Here's a simple example that hits this issue:

import pickle                                             
from lru import LRU                                       
                                                          
key_limit = 10                                            
a = LRU(key_limit)                                        
for i in range(key_limit - 5):                            
    a[i] = key_limit - i                                  
print(a[0])                                               
                                                          
with open("/vol/data0/tmp/example_lru.pkl",'wb') as f:     
    print("Saving LRU")                                   
    pickle.dump(a, f, pickle.HIGHEST_PROTOCOL)            
                                                          
                                                          
with open("/vol/data0/tmp/example_lru.pkl",'rb') as f:     
    print("Loading LRU")                                  
    b = pickle.load(f)                                    
                                                          
print(b[0])                                               

Output:

10
Saving LRU
Loading LRU
Segmentation fault (core dumped)

Not sure if you've intended the LRU to survive serialization / deserialization, but if not I'd understand closing this.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions