sylvestre.ledru created this revision.
sylvestre.ledru added a project: clang.

gcov / gcda-based profiling crashes when shared libraries are unloaded

Patch by Benoit Belley and tested by Marco Castelluccio for Firefox

See https://bugs.llvm.org/show_bug.cgi?id=27224 & 
https://bugzilla.mozilla.org/show_bug.cgi?id=1401230


https://reviews.llvm.org/D38124

Files:
  lib/profile/GCDAProfiling.c

Index: lib/profile/GCDAProfiling.c
===================================================================
--- lib/profile/GCDAProfiling.c
+++ lib/profile/GCDAProfiling.c
@@ -21,6 +21,7 @@
 \*===----------------------------------------------------------------------===*/
 
 #include "InstrProfilingUtil.h"
+#include "InstrProfilingPort.h" /* for COMPILER_RT_VISIBILITY */
 
 #include <errno.h>
 #include <fcntl.h>
@@ -251,6 +252,7 @@
  * profiling enabled will emit to a different file. Only one file may be
  * started at a time.
  */
+COMPILER_RT_VISIBILITY
 void llvm_gcda_start_file(const char *orig_filename, const char version[4],
                           uint32_t checksum) {
   const char *mode = "r+b";
@@ -318,6 +320,7 @@
 /* Given an array of pointers to counters (counters), increment the n-th one,
  * where we're also given a pointer to n (predecessor).
  */
+COMPILER_RT_VISIBILITY
 void llvm_gcda_increment_indirect_counter(uint32_t *predecessor,
                                           uint64_t **counters) {
   uint64_t *counter;
@@ -340,6 +343,7 @@
 #endif
 }
 
+COMPILER_RT_VISIBILITY
 void llvm_gcda_emit_function(uint32_t ident, const char *function_name,
                              uint32_t func_checksum, uint8_t use_extra_checksum,
                              uint32_t cfg_checksum) {
@@ -366,6 +370,7 @@
     write_string(function_name);
 }
 
+COMPILER_RT_VISIBILITY
 void llvm_gcda_emit_arcs(uint32_t num_counters, uint64_t *counters) {
   uint32_t i;
   uint64_t *old_ctrs = NULL;
@@ -417,6 +422,7 @@
 #endif
 }
 
+COMPILER_RT_VISIBILITY
 void llvm_gcda_summary_info() {
   const uint32_t obj_summary_len = 9; /* Length for gcov compatibility. */
   uint32_t i;
@@ -470,6 +476,7 @@
 #endif
 }
 
+COMPILER_RT_VISIBILITY
 void llvm_gcda_end_file() {
   /* Write out EOF record. */
   if (output_file) {
@@ -494,6 +501,7 @@
 #endif
 }
 
+COMPILER_RT_VISIBILITY
 void llvm_register_writeout_function(writeout_fn fn) {
   struct writeout_fn_node *new_node = malloc(sizeof(struct writeout_fn_node));
   new_node->fn = fn;
@@ -507,6 +515,7 @@
   }
 }
 
+COMPILER_RT_VISIBILITY
 void llvm_writeout_files() {
   struct writeout_fn_node *curr = writeout_fn_head;
 
@@ -516,6 +525,7 @@
   }
 }
 
+COMPILER_RT_VISIBILITY
 void llvm_delete_writeout_function_list() {
   while (writeout_fn_head) {
     struct writeout_fn_node *node = writeout_fn_head;
@@ -526,6 +536,7 @@
   writeout_fn_head = writeout_fn_tail = NULL;
 }
 
+COMPILER_RT_VISIBILITY
 void llvm_register_flush_function(flush_fn fn) {
   struct flush_fn_node *new_node = malloc(sizeof(struct flush_fn_node));
   new_node->fn = fn;
@@ -539,6 +550,7 @@
   }
 }
 
+COMPILER_RT_VISIBILITY
 void __gcov_flush() {
   struct flush_fn_node *curr = flush_fn_head;
 
@@ -548,6 +560,7 @@
   }
 }
 
+COMPILER_RT_VISIBILITY
 void llvm_delete_flush_function_list() {
   while (flush_fn_head) {
     struct flush_fn_node *node = flush_fn_head;
@@ -558,6 +571,7 @@
   flush_fn_head = flush_fn_tail = NULL;
 }
 
+COMPILER_RT_VISIBILITY
 void llvm_gcov_init(writeout_fn wfn, flush_fn ffn) {
   static int atexit_ran = 0;
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D38124: Hide some ... Sylvestre Ledru via Phabricator via cfe-commits

Reply via email to