Combine backtrace print into one string to avoid interleaving. (#56961)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/56961
As described in https://github.com/pytorch/pytorch/issues/56583, the
backtrace amongst several processes was garbled.
https://github.com/pytorch/pytorch/pull/56198 would've alleviated this to some
extent, but this PR combines all the logging into just one string to reduce
interleaving further.
ghstack-source-id: 128730047
Test Plan: waitforbuildbot
Reviewed By: cbalioglu
Differential Revision: D28013191
fbshipit-source-id: 8bd8978a92ee2fbcd18472e1293d5809455b411b