From 585afbbc6a833e91cd2e51b8faeece2248c0cc16 Mon Sep 17 00:00:00 2001 From: kosaki Date: Fri, 21 Dec 2012 17:21:12 +0000 Subject: [PATCH] * vm_dump.c (rb_vm_bugreport): revert r38533. * addr2line.c (fill_lines): add ELF sanity check. [Bug #7597] [ruby-dev:46786] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38543 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ addr2line.c | 11 ++++++++++- vm_dump.c | 9 ++++----- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9af87a49e3..264d7aaba2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sat Dec 22 02:19:38 2012 KOSAKI Motohiro + + * vm_dump.c (rb_vm_bugreport): revert r38533. + * addr2line.c (fill_lines): add ELF sanity check. + [Bug #7597] [ruby-dev:46786] + Sat Dec 22 02:05:00 2012 Zachary Scott * lib/irb/inspector.rb, lib/irb/context.rb: Move IRB::INSPECTORS and diff --git a/addr2line.c b/addr2line.c index e102abba4f..04a48e751d 100644 --- a/addr2line.c +++ b/addr2line.c @@ -493,6 +493,16 @@ fill_lines(int num_traces, void **traces, char **syms, int check_debuglink, return; } + ehdr = (ElfW(Ehdr) *)file; + if (memcmp(ehdr->e_ident, "\177ELF", 4) != 0) { + /* + * Huh? Maybe filename was overridden by setproctitle() and + * it match non-elf file. + */ + close(fd); + return; + } + current_line->fd = fd; current_line->mapped = file; current_line->mapped_size = (size_t)filesize; @@ -506,7 +516,6 @@ fill_lines(int num_traces, void **traces, char **syms, int check_debuglink, } } - ehdr = (ElfW(Ehdr) *)file; shdr = (ElfW(Shdr) *)(file + ehdr->e_shoff); shstr_shdr = shdr + ehdr->e_shstrndx; diff --git a/vm_dump.c b/vm_dump.c index 50d3ebfdf5..292280c40f 100644 --- a/vm_dump.c +++ b/vm_dump.c @@ -644,15 +644,14 @@ rb_vm_bugreport(void) char **syms = backtrace_symbols(trace, n); if (syms) { -/* commentout temporarily. we have to fix addr2line. see [Bug #7597] */ -/* #ifdef USE_ELF */ -/* rb_dump_backtrace_with_lines(n, trace, syms); */ -/* #else */ +#ifdef USE_ELF + rb_dump_backtrace_with_lines(n, trace, syms); +#else int i; for (i=0; i