Moved the new stack trace logging function and added a call to it from
(set-permissions).