Concurrent calls to rig_debug() could use the same temporary buffer and corrupt the saved debug history. Give each call its own buffer and update the shared history under the existing mutex. (cherry picked from commit cf3fcc4b8a)
cf3fcc4b8a