S.H.
Did you see a Pediatric Gastroenterologist?
That is the kind of Doctor you should see, if you have not already.
Not just a Pediatrician.
There is also something called 'Encopresis" which is an involuntary leaking of poop. Often times, as a result of constipation.
So, this should be considered as well.
Again, see a specialist, a Ped Gastroenterologist.
Constipation... causes pain. Thus, the child starts to 'withhold' it. This makes it worse and internally. Bulging bowels, encopresis, etc.
Is he potty training or something? Kids, OFTEN per potty training, will 'withhold' their poop. It is then a vicious cycle and 2-fold: emotion based due to the pain and fear of pooping, AND also, medically and physically a problem.