Fix an occasional crash when loading Automation scripts

cmd::reg and AssExportFilterChain::Register are not thread-safe, so
guard them with a mutex.
Don't try to add stack traces to non-string errors