I think the physics of the situation don't make a barrier feasible: a derailed train going >100 mph is going to transfer a lot of energy to any kind of barrier it impacts, which in turn might exacerbate the situation (by spreading debris).
I think these kinds of accidents are largely mitigated by rail defect monitoring. I know rails in the US are equipped with defect detectors for passing trains; I'm surprised that a similar system doesn't exist for the rails themselves. Or more likely, one does exist and the outcome of this tragedy will be a lesson about operational failures.
In principle only, if a barrier could keep a train on its side of the barrier, scraping along the barrier for a long distance instead of smashing headfirst into it, the energy could be dissipated over a long period of time, preventing fatalities. But what kind of barrier can withstand a train?