axiak / pyre2

Python wrapper for RE2
BSD 3-Clause "New" or "Revised" License
295 stars 39 forks source link

Corrupted compiled re2 object causes seg fault #30

Open EliezerIsrael opened 9 years ago

EliezerIsrael commented 9 years ago

This is as much for other users as for the developers.

I'm using re2 in a Django app, and stored a large compiled re2 regex in a Redis cache. When I pulled it out of the cache, the 'pattern' attribute didn't make it out alive - it was 'None'. Naively using the object's 'match' method caused a segmentation fault.

Simple solution - don't store compiled regexs in Redis.

Perhaps there is also room here for the code to fail a bit more gracefully.