aboutsummaryrefslogtreecommitdiff
path: root/libgo/runtime
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2015-03-09 23:40:58 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2015-03-09 23:40:58 +0000
commit4729d7726bdc86c46aeb525270909b73490ce206 (patch)
tree1a0a01f1fe702feadf8fd20a3cf9fa97c02fd779 /libgo/runtime
parent864396ff9e8a4ee1f02e1ff0fb4d096bbca547ff (diff)
downloadgcc-4729d7726bdc86c46aeb525270909b73490ce206.zip
gcc-4729d7726bdc86c46aeb525270909b73490ce206.tar.gz
gcc-4729d7726bdc86c46aeb525270909b73490ce206.tar.bz2
re PR go/65349 (go tool crashes, can't compile go code on 32bit linux systems)
PR go/65349 runtime: Don't call malloc from __go_file_line callback. When crashing, we call runtime_printcreatedby which calls __go_file_line which used to call the Go malloc. If we are crashing due to a signal due to heap corruption of some sort, the GO malloc lock might already be held, leading to a crash within a crash. Avoid that by assuming that the libbacktrace strings will stick around, as we already do in go-callers.c. From-SVN: r221291
Diffstat (limited to 'libgo/runtime')
-rw-r--r--libgo/runtime/go-caller.c36
1 files changed, 6 insertions, 30 deletions
diff --git a/libgo/runtime/go-caller.c b/libgo/runtime/go-caller.c
index 7fcdf20..ad151ec 100644
--- a/libgo/runtime/go-caller.c
+++ b/libgo/runtime/go-caller.c
@@ -37,36 +37,12 @@ callback (void *data, uintptr_t pc __attribute__ ((unused)),
{
struct caller *c = (struct caller *) data;
- if (function == NULL)
- {
- c->fn.str = NULL;
- c->fn.len = 0;
- }
- else
- {
- byte *s;
-
- c->fn.len = __builtin_strlen (function);
- s = runtime_malloc (c->fn.len);
- __builtin_memcpy (s, function, c->fn.len);
- c->fn.str = s;
- }
-
- if (filename == NULL)
- {
- c->file.str = NULL;
- c->file.len = 0;
- }
- else
- {
- byte *s;
-
- c->file.len = __builtin_strlen (filename);
- s = runtime_malloc (c->file.len);
- __builtin_memcpy (s, filename, c->file.len);
- c->file.str = s;
- }
-
+ /* 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. */
+ c->fn = runtime_gostringnocopy ((const byte *) function);
+ c->file = runtime_gostringnocopy ((const byte *) filename);
c->line = lineno;
return 0;