Thank you very much. I just tested pruning on the original case with the patch you sent and confirm segfaults went away. Regarding hash aggregation, I'll try to find a test case and follow up within a day or so (cloning a huge db right now).
pgsql-bugs by date:
Соглашаюсь с условиями обработки персональных данных