runtime: Don't allocate when doing a backtrace.
authorIan Lance Taylor <ian@gcc.gnu.org>
Thu, 31 Jan 2013 16:41:15 +0000 (16:41 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Thu, 31 Jan 2013 16:41:15 +0000 (16:41 +0000)
From-SVN: r195615

libgo/runtime/go-callers.c

index ea6b5db1bcb2b8f6462bc7d387d6758545532afc..2154a8ae4af6fa3084dc4188b91b3afb576d5f46 100644 (file)
@@ -43,8 +43,14 @@ callback (void *data, uintptr_t pc, const char *filename, int lineno,
 
   loc = &arg->locbuf[arg->index];
   loc->pc = pc;
-  loc->filename = runtime_gostring ((const byte *) filename);
-  loc->function = runtime_gostring ((const byte *) function);
+
+  /* The libbacktrace library says that these strings might disappear,
+     but with the current implementation they won't.  We can't easily
+     allocate memory here, so for now assume that we can save a
+     pointer to the strings.  */
+  loc->filename = runtime_gostringnocopy ((const byte *) filename);
+  loc->function = runtime_gostringnocopy ((const byte *) function);
+
   loc->lineno = lineno;
   ++arg->index;
   return arg->index >= arg->max;