X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=bin%2Foverride.c;h=60bee0ce3eebfa21a527a5359bbc9a82da79f087;hb=6c948b6dfde5d0edd4b1975ff8a4a0f89fd9e2c9;hp=113a63844597d4f61151616d6e9ab350bdf9972d;hpb=209c152e39ae22bf3842ff81f5b829c099d3aae7;p=vlc diff --git a/bin/override.c b/bin/override.c index 113a638445..60bee0ce3e 100644 --- a/bin/override.c +++ b/bin/override.c @@ -38,6 +38,9 @@ void vlc_enable_override (void); #ifdef HAVE_EXECINFO_H # include #endif +#ifdef NDEBUG +# undef HAVE_BACKTRACE +#endif static bool override = false; @@ -56,7 +59,7 @@ static void vlogbug (const char *level, const char *func, const char *fmt, va_list ap) { #ifdef HAVE_BACKTRACE - const size_t framec = 8; + const size_t framec = 4; void *framev[framec]; backtrace (framev, framec); @@ -86,7 +89,8 @@ static void *getsym (const char *name) void *sym = dlsym (RTLD_NEXT, name); if (sym == NULL) { - fprintf (stderr, "Cannot resolve symbol %s!\n", name); + fprintf (stderr, "Cannot resolve symbol %s: %s\n", name, + dlerror ()); abort (); } return sym; @@ -192,6 +196,24 @@ int sigaction (int signum, const struct sigaction *act, struct sigaction *old) } +/*** Locales *** + * setlocale() is not thread-safe and has a tendency to crash other threads as + * quite many libc and libintl calls depend on the locale. + * Use uselocale() instead for thread-safety. + */ +#include + +char *setlocale (int cat, const char *locale) +{ + if (override && locale != NULL) + { + LOG("Blocked", "%d, \"%s\"", cat, locale); + return NULL; + } + return CALL(setlocale, cat, locale); +} + + /*** Xlib ****/ #ifdef HAVE_X11_XLIB_H # include @@ -230,7 +252,7 @@ int (*XSetIOErrorHandler (int (*handler) (Display *))) (Display *) } #endif #else -static void vlc_enable_override (void) +void vlc_enable_override (void) { } #endif