This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
locale.c: Unlock mutex before croaking
authorKarl Williamson <khw@cpan.org>
Sun, 6 Dec 2020 23:29:11 +0000 (16:29 -0700)
committerKarl Williamson <khw@cpan.org>
Tue, 8 Dec 2020 13:44:20 +0000 (06:44 -0700)
These cases aren't supposed to happen, but unlock the mutex first;
we could get into deadlock in trying to output the death message.

locale.c

index e43de9f..9eb49be 100644 (file)
--- a/locale.c
+++ b/locale.c
@@ -5362,6 +5362,7 @@ Perl_my_strerror(pTHX_ const int errnum)
     if (! within_locale_scope) {
         save_locale = do_setlocale_c(LC_MESSAGES, NULL);
         if (! save_locale) {
+            SETLOCALE_UNLOCK;
             Perl_croak(aTHX_
                  "panic: %s: %d: Could not find current LC_MESSAGES locale,"
                  " errno=%d\n", __FILE__, __LINE__, errno);
@@ -5391,6 +5392,7 @@ Perl_my_strerror(pTHX_ const int errnum)
     if (! within_locale_scope) {
         if (save_locale && ! locale_is_C) {
             if (! do_setlocale_c(LC_MESSAGES, save_locale)) {
+                SETLOCALE_UNLOCK;
                 Perl_croak(aTHX_
                      "panic: %s: %d: setlocale restore to '%s' failed, errno=%d\n",
                              __FILE__, __LINE__, save_locale, errno);