After MH iterations, the computations can get stuck on marginal_density.m because of a log(0).

If you have this problem, you can use this fix: using determinant properties, replace log(detSIGMA) with logdetSIGMA that is defined as
logdetSIGMA = 2*log(det(chol(SIGMA)));

See attached file, it’s a modification of the 4.2 version of Dynare.