The new, small, free_readfile managed to have bug in it which could cause it to try and free something it shouldn't, and fix the case where it was being called with an invalid pointer leading to a segfault.
Noted by Bruce, issues introduced and fixed by me.
Yeah, this has fixed the segfaults, thanks.
Now I get an issue when restarting my cluster, but not when I stop and start:
thom@swift ~/dbtest $ pg_ctl stop -D primary
waiting for server to shut down.... done
server stopped
thom@swift ~/dbtest $ pg_ctl start -D primary
server starting
thom@swift ~/dbtest $ 2014-03-05 11:46:21.963 GMT - - LOG: redirecting log output to logging collector process
2014-03-05 11:46:21.963 GMT - - HINT: Future log output will appear in directory "pg_log".