[BRLTTY] Crash of BRLTTY in X sessionudo systemctl edit brlpulse

Samuel Thibault samuel.thibault at ens-lyon.org
Tue Mar 4 13:48:26 UTC 2025


Hello,

Sebastian Humenda, le lun. 03 mars 2025 18:07:24 +0100, a ecrit:
> Apparently it makes a difference whether I use asan_symbolize or
> llvm-symbolizer, the latter maybe being for a different purpose. Symbolized
> output below. Thanks!

>     #0 0x7f7e998d0d66 in __sanitizer::internal_strlen(char const*) ../../../../src/libsanitizer/sanitizer_common/sanitizer_libc.cpp:167
>     #1 0x7f7e9986dc9f in unpoison_glob_t ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:2304
>     #2 0x7f7e9986e292 in __interceptor_glob ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:2380

This looks like the libasan bug we had seen before. Did you apply my
attached patch to avoid it?

Samuel
-------------- next part --------------
diff --git a/Programs/menu.c b/Programs/menu.c
index a1a91ec35..659da0037 100644
--- a/Programs/menu.c
+++ b/Programs/menu.c
@@ -60,6 +60,7 @@ typedef struct {
 
 #if defined(HAVE_GLOB)
   glob_t glob;
+  char **copy;
 #elif defined(__MINGW32__)
   char **names;
   int offset;
@@ -559,17 +560,15 @@ beginItem_files (MenuItem *item) {
       if (chdir(files->directory) != -1) {
 #if defined(HAVE_GLOB)
         memset(&files->glob, 0, sizeof(files->glob));
-        files->glob.gl_offs = files->count;
 
-        if (glob(files->pattern, GLOB_DOOFFS, NULL, &files->glob) == 0) {
-          files->paths = files->glob.gl_pathv;
-
-          /* The behaviour of gl_pathc is inconsistent. Some implementations
-           * include the leading NULL pointers and some don't. Let's just
-           * figure it out the hard way by finding the trailing NULL.
-           */
-          while (files->paths[files->count]) files->count += 1;
+        if (glob(files->pattern, 0, NULL, &files->glob) == 0) {
+          files->copy = malloc((index + files->glob.gl_pathc + 1) * sizeof(*files->paths));
+          memcpy(files->copy + index, files->glob.gl_pathv, (files->glob.gl_pathc + 1) * sizeof(*files->paths));
+          files->count += files->glob.gl_pathc;
+          files->paths = files->copy;
         }
+        else
+          files->copy = NULL;
 #elif defined(__MINGW32__)
         struct _finddata_t findData;
         long findHandle = _findfirst(files->pattern, &findData);
@@ -656,7 +655,7 @@ endItem_files (MenuItem *item, int deallocating) {
 
 #if defined(HAVE_GLOB)
   if (files->glob.gl_pathc) {
-    for (int i=0; i<files->glob.gl_offs; i+=1) files->glob.gl_pathv[i] = NULL;
+    free(files->copy);
     globfree(&files->glob);
     files->glob.gl_pathc = 0;
   }


More information about the BRLTTY mailing list