I found a very simple repro on my machine
postgres=# select x, x, lpad('string', 100, x::text) from generate_series(1, 10000000) x;
Killed
So this is just about fetching huge data through psql.
But if I reduce the number of rows by 10 times, it gives result without getting killed.
[ashutosh@ubuntu repro]psql -d postgres
psql (9.4devel)
Type "help" for help.
postgres=# select x, x, lpad('string', 100, x::text) from generate_series(1, 1000000) x;
x | x | lpad
---------+---------+------------------------------------------------------------------------------------------------------
1 | 1 | 1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111string
May be each setup has it's own breaking point. So trying with larger number might reproduce the issue.
I tried to debug it with gdb, but all it showed me was that psql received a SIGKILL signal. I am not sure why.