Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PATCH] fix symbol search loop at debuglink mode #70

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,7 @@ static int
elf_try_debugfile (struct backtrace_state *state, const char *prefix,
size_t prefix_len, const char *prefix2, size_t prefix2_len,
const char *debuglink_name,
const char *ref_filename,
backtrace_error_callback error_callback, void *data)
{
size_t debuglink_len;
Expand All @@ -936,6 +937,9 @@ elf_try_debugfile (struct backtrace_state *state, const char *prefix,
memcpy (try + prefix_len + prefix2_len, debuglink_name, debuglink_len);
try[prefix_len + prefix2_len + debuglink_len] = '\0';

if(ref_filename && *ref_filename && !strcmp(try, ref_filename))
return -1; // loop detected

ret = backtrace_open (try, error_callback, data, &does_not_exist);

backtrace_free (state, try, try_len, error_callback, data);
Expand Down Expand Up @@ -1026,7 +1030,8 @@ elf_find_debugfile_by_debuglink (struct backtrace_state *state,
}

ddescriptor = elf_try_debugfile (state, prefix, prefix_len, "", 0,
debuglink_name, error_callback, data);
debuglink_name, filename,
error_callback, data);
if (ddescriptor >= 0)
{
ret = ddescriptor;
Expand All @@ -1037,7 +1042,7 @@ elf_find_debugfile_by_debuglink (struct backtrace_state *state,

ddescriptor = elf_try_debugfile (state, prefix, prefix_len, ".debug/",
strlen (".debug/"), debuglink_name,
error_callback, data);
filename, error_callback, data);
if (ddescriptor >= 0)
{
ret = ddescriptor;
Expand All @@ -1049,7 +1054,7 @@ elf_find_debugfile_by_debuglink (struct backtrace_state *state,
ddescriptor = elf_try_debugfile (state, "/usr/lib/debug/",
strlen ("/usr/lib/debug/"), prefix,
prefix_len, debuglink_name,
error_callback, data);
filename, error_callback, data);
if (ddescriptor >= 0)
ret = ddescriptor;

Expand Down