Occure in version: 8.0 and higher, I try it also in devel version 8.5b1 and the problem is still here.
regexp '($|^X)*' 'foo'
The problem is in regular expressions code, which results in a non-terminating infinite loop during nondeterministic finite automata optimization. These loops remain even after the client disconnects and can be used to hog CPU and connections to the database until a full-fledged denial of service condition occurs.
I try to attach patch soon, but at the moment I've no idea, where in code is the problem.