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

fix: #1858 by changing the wrong logic in update_dbg_info #1884

Merged
merged 1 commit into from
Feb 9, 2024

Conversation

yihong0618
Copy link
Contributor

@yihong0618 yihong0618 commented Feb 8, 2024

by changing the wrong logic in update_dbg_info

backtrace(need set follow-fork-mode child)

__memmove_avx_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:457
457	../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S: No such file or directory.
#0  __memmove_avx_unaligned_erms () at ../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:457
#1  0x00007ffff7c8de6c in __GI__IO_default_xsputn (n=<optimized out>, data=<optimized out>, f=<optimized out>) at ./libio/genops.c:386
#2  __GI__IO_default_xsputn (f=0x7fffffff7a10, data=<optimized out>, n=174) at ./libio/genops.c:370
#3  0x00007ffff7c74918 in outstring_func (done=0, length=174, 
    string=0x55555c1634d0 "F: 723bd tensorflow._api.v2.experimental.numpy.random.<module>\nL: 1 /home/yihong/.local/lib/python3.10/site-packages/tensorflow/_api/v2/experimental/numpy/random/__init__.py\n", s=0x7fffffff7440) at ../libio/libioP.h:947
#4  printf_positional (s=s@entry=0x7fffffff7a10, format=format@entry=0x7ffff62d1911 "%s", readonly_format=<optimized out>, readonly_format@entry=0, ap=ap@entry=0x7fffffff7b90, 
    ap_savep=ap_savep@entry=0x7fffffff75a8, done=<optimized out>, done@entry=0, nspecs_done=<optimized out>, lead_str_end=<optimized out>, work_buffer=<optimized out>, 
    save_errno=<optimized out>, grouping=<optimized out>, thousands_sep=<optimized out>, mode_flags=<optimized out>) at ./stdio-common/vfprintf-internal.c:1927
#5  0x00007ffff7c75336 in __vfprintf_internal (s=s@entry=0x7fffffff7a10, format=format@entry=0x7ffff62d1911 "%s", ap=ap@entry=0x7fffffff7b90, mode_flags=mode_flags@entry=0)
    at ./stdio-common/vfprintf-internal.c:1602
#6  0x00007ffff7c8849a in __vsnprintf_internal (string=0x7ffff4ffffeb "", maxlen=<optimized out>, format=0x7ffff62d1911 "%s", args=args@entry=0x7fffffff7b90, mode_flags=mode_flags@entry=0)
    at ./libio/vsnprintf.c:114
#7  0x00007ffff7c60856 in __GI___snprintf (s=s@entry=0x7ffff4ffffeb "", maxlen=maxlen@entry=175, format=format@entry=0x7ffff62d1911 "%s") at ./stdio-common/snprintf.c:31
#8  0x00007ffff62cc1be in snprintf (__fmt=0x7ffff62d1911 "%s", __n=175, __s=0x7ffff4ffffeb "") at /usr/include/x86_64-linux-gnu/bits/stdio2.h:71
#9  update_dbg_info (line=<optimized out>, file=<optimized out>, addr=<optimized out>, name=<optimized out>) at /home/yihong/repos/uftrace/python/trace-python.c:403
#10 convert_function_addr (is_pyfunc=<optimized out>, args=<optimized out>, frame=<optimized out>) at /home/yihong/repos/uftrace/python/trace-python.c:943
#11 uftrace_trace_python (self=<optimized out>, args=<optimized out>) at /home/yihong/repos/uftrace/python/trace-python.c:976

@honggyukim
Copy link
Collaborator

Thanks very much for the fix! Could you please update the commit message following our commit message convention? The current commit title is too long and we tend to make the title and commit message short. Please read the discussion at https://stackoverflow.com/questions/2290016/git-commit-messages-50-72-formatting.

@yihong0618
Copy link
Contributor Author

yihong0618 commented Feb 8, 2024

Thanks very much for the fix! Could you please update the commit message following our commit message convention? The current commit title is too long and we tend to make the title and commit message short. Please read the discussion at https://stackoverflow.com/questions/2290016/git-commit-messages-50-72-formatting.

Done, and do we need to add comments to the line of #define UFTRACE_PYTHON_SYMTAB_SIZE (2 * 1024 * 1024)
I did search the code base, there's no such comments like that, so I did not add it.

@yihong0618 yihong0618 changed the title fix: #1858 fix: #1858 by increasing UFTRACE_PYTHON_SYMTAB_SIZE default size to 2MB Feb 8, 2024
@honggyukim
Copy link
Collaborator

Thanks. But I just found that the root cause is in different reason. The following would be more proper fix.

diff --git a/python/trace-python.c b/python/trace-python.c
index a0636b35..f6adc490 100644
--- a/python/trace-python.c
+++ b/python/trace-python.c
@@ -382,7 +382,7 @@ static void update_dbg_info(const char *name, uint64_t addr, const char *file, i
                old_hdr.val = tmp_hdr.val;
        }

-       if (new_hdr.offset >= uftrace_symtab_size) {
+       if (new_hdr.offset >= uftrace_dbginfo_size) {
                unsigned new_dbginfo_size = uftrace_dbginfo_size + UFTRACE_PYTHON_SYMTAB_SIZE;

                pr_dbg("try to increase the shared memory for %s (new size=%uMB)\n",

I think the original code at update_dbg_info was incorrectly written because it got confused with get_new_sym_addr.

@honggyukim
Copy link
Collaborator

honggyukim commented Feb 8, 2024

We also need to be sure that entry_size + 1 is less than UFTRACE_PYTHON_SYMTAB_SIZE.

@yihong0618
Copy link
Contributor Author

uftrace_dbginfo_size

nice catch, will change the root cause.

@yihong0618
Copy link
Contributor Author

We also need to be sure that entry_size + 1 is less than UFTRACE_PYTHON_SYMTAB_SIZE.

I think we do not need to consider it seems always less than UFTRACE_PYTHON_SYMTAB_SIZE

	int entry_size = strlen(name) + 20; /* addr(16) + spaces(2) + type(1) + newline(1) */

@yihong0618
Copy link
Contributor Author

@honggyukim you are right, the root cause it the logic, also change the logic from if to while

@honggyukim
Copy link
Collaborator

I think we do not need to consider it seems always less than UFTRACE_PYTHON_SYMTAB_SIZE

Yeah, we won't need it for both get_new_sym_addr and update_dbg_info.

int entry_size = xasprintf(&buf, "F: %" PRIx64 " %s\nL: %d %s\n", addr, name, line, file);

So please apply the uftrace_dbginfo_size change only and make the commit message as follows.

python: Fix incorrect comparison in update_dbg_info

The logic to increase uftrace_dbginfo_size should be compared
with uftrace_dbginfo_size instead of uftrace_symtab_size.

This looks like a mistake due to confusion with get_new_sym_addr.

Fixed: #1858
Signed-off-by: Yi Hong <zouzou0208@gmail.com>
Signed-off-by: Honggyu Kim <honggyu.kp@gmail.com>

@yihong0618 yihong0618 changed the title fix: #1858 by increasing UFTRACE_PYTHON_SYMTAB_SIZE default size to 2MB fix: #1858 by changing the wrong logic in update_dbg_info Feb 8, 2024
@@ -261,7 +261,7 @@ static uint32_t get_new_sym_addr(const char *name, bool is_libcall)
old_hdr.val = tmp_hdr.val;
}

if (new_hdr.offset >= uftrace_symtab_size) {
while (new_hdr.offset >= uftrace_symtab_size) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to use while. Please revert it back to if.

@@ -382,7 +382,7 @@ static void update_dbg_info(const char *name, uint64_t addr, const char *file, i
old_hdr.val = tmp_hdr.val;
}

if (new_hdr.offset >= uftrace_symtab_size) {
while (new_hdr.offset >= uftrace_dbginfo_size) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

@yihong0618
Copy link
Contributor Author

I think we do not need to consider it seems always less than UFTRACE_PYTHON_SYMTAB_SIZE

Yeah, we won't need it for both get_new_sym_addr and update_dbg_info.

int entry_size = xasprintf(&buf, "F: %" PRIx64 " %s\nL: %d %s\n", addr, name, line, file);

So please apply the uftrace_dbginfo_size change only and make the commit message as follows.

python: Fix incorrect comparison in update_dbg_info

The logic to increase uftrace_dbginfo_size should be compared
with uftrace_dbginfo_size instead of uftrace_symtab_size.

This looks like a mistake due to confusion with get_new_sym_addr.

Fixed: #1858
Signed-off-by: Yi Hong <zouzou0208@gmail.com>
Signed-off-by: Honggyu Kim <honggyu.kp@gmail.com>

nice commit message, learned that.

@honggyukim
Copy link
Collaborator

FYI, Fixed: #1858 is detected by GitHub. That means if this commit is merged into master, then the issue #1858 is automatically closed.

The logic to increase uftrace_dbginfo_size should be compared
with uftrace_dbginfo_size instead of uftrace_symtab_size.

This looks like a mistake due to confusion with get_new_sym_addr.

Fixed: namhyung#1858
Signed-off-by: Yi Hong <zouzou0208@gmail.com>
Signed-off-by: Honggyu Kim <honggyu.kp@gmail.com>
@yihong0618
Copy link
Contributor Author

@honggyukim Done and thanks, I learn from your careful review every time, thanks again!

Copy link
Collaborator

@honggyukim honggyukim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks very much! I will wait for @namhyung's final check.

Copy link
Owner

@namhyung namhyung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the fix!

@namhyung namhyung merged commit ecca1ec into namhyung:master Feb 9, 2024
3 checks passed
@yihong0618 yihong0618 deleted the fix_issue_1858 branch February 12, 2024 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants