[前][次][番号順一覧][スレッド一覧]

ruby-changes:52126

From: naruse <ko1@a...>
Date: Mon, 13 Aug 2018 17:48:36 +0900 (JST)
Subject: [ruby-changes:52126] naruse:r64334 (trunk): Don't free allocated uncompressed_debug_line until backtrace is printed

naruse	2018-08-13 17:48:30 +0900 (Mon, 13 Aug 2018)

  New Revision: 64334

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=64334

  Log:
    Don't free allocated uncompressed_debug_line until backtrace is printed

  Modified files:
    trunk/addr2line.c
Index: addr2line.c
===================================================================
--- addr2line.c	(revision 64333)
+++ addr2line.c	(revision 64334)
@@ -127,6 +127,7 @@ struct obj_info { https://github.com/ruby/ruby/blob/trunk/addr2line.c#L127
     const char *path; /* object path */
     void *mapped;
     size_t mapped_size;
+    void *uncompressed_debug_line;
     uintptr_t base_addr;
     obj_info_t *next;
 };
@@ -503,20 +504,18 @@ parse_compressed_debug_line(int num_trac https://github.com/ruby/ruby/blob/trunk/addr2line.c#L504
     if (!uncompressed_debug_line) return -1;
     ret = uncompress(uncompressed_debug_line, &destsize,
 	    (const Bytef *)debug_line + sizeof(ElfW(Chdr)), size-sizeof(ElfW(Chdr)));
-    if (ret != Z_OK) { /* Z_OK = 0 */
-	goto finish;
-    }
+    if (ret != Z_OK) goto fail;
     ret = parse_debug_line(num_traces, traces,
 	    uncompressed_debug_line,
 	    destsize,
 	    obj, lines, offset);
-    if (ret) {
-	goto finish;
-    }
+    if (ret) goto fail;
+    obj->uncompressed_debug_line = uncompressed_debug_line;
+    return 0;
 
-finish:
+fail:
     free(uncompressed_debug_line);
-    return ret ? -1 : 0;
+    return -1;
 }
 #endif
 
@@ -843,6 +842,9 @@ next_line: https://github.com/ruby/ruby/blob/trunk/addr2line.c#L842
 	if (o->mapped_size) {
 	    munmap(o->mapped, o->mapped_size);
 	}
+        if (o->uncompressed_debug_line) {
+            free(o->uncompressed_debug_line);
+        }
 	free(o);
     }
     free(lines);

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]