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

Offset outside the function bounds #6

Open
xqms opened this issue Apr 7, 2022 · 4 comments
Open

Offset outside the function bounds #6

xqms opened this issue Apr 7, 2022 · 4 comments
Labels
upstream Waiting on an external dependency to be fixed first

Comments

@xqms
Copy link

xqms commented Apr 7, 2022

Hey, great tool!

I'm seeing error messages like these whenever I try to trace a line with "x": (the initial tracepoint on main works)

Error: bpftrace command 'BEGIN { @start_time = nsecs; @depth[-1] = 0; @matched_retfilters[-1] = 0; } uprobe:/home/max/projects/uni/avatar/build/imgui_ros/devel/lib/imgui_ros/gui:main /@depth[tid] == 0/ { @start147[tid] = nsecs; @depth[tid] = 1; } uretprobe:/home/max/projects/uni/avatar/build/imgui_ros/devel/lib/imgui_ros/gui:main /@depth[tid] == 1/ { @duration_tmp147[tid] += (nsecs - @start147[tid]); $duration = @duration_tmp147[tid]; @count_tmp147[tid] += 1; delete(@start147[tid]); @depth[tid] = 0; if (@matched_retfilters[tid] == 0) { @duration171 += @duration_tmp171[tid]; @count171 += @count_tmp171[tid]; @duration147 += @duration_tmp147[tid]; @count147 += @count_tmp147[tid]; } delete(@duration_tmp171[tid]); delete(@count_tmp171[tid]); delete(@duration_tmp147[tid]); delete(@count_tmp147[tid]); delete(@matched_retfilters[tid]); } uprobe:/home/max/projects/uni/avatar/build/imgui_ros/devel/lib/imgui_ros/gui:main+1011 /@depth[tid] == 1/ { @start171[tid] = nsecs; } uprobe:/home/max/projects/uni/avatar/build/imgui_ros/devel/lib/imgui_ros/gui:main+1016 /@depth[tid] == 1 && @start171[tid]/ { @duration_tmp171[tid] += (nsecs - @start171[tid]); @count_tmp171[tid] += 1; delete(@start171[tid]); } interval:s:1 { printf("{\"time\": %d, \"lines\": {", (nsecs - @start_time) / 1000000000); printf("\"171\": [%lld, %lld], ", @duration171, @count171); printf("\"147\": [%lld, %lld]", @duration147, @count147); printf("}}\n"); }' failed, status: ExitStatus(ExitStatus(65280)), stderr:
ERROR: Offset outside the function bounds ('_ZZ4mainENKUlvE_clEv' size is 303)

Versions:

bpftrace v0.14.0-93-g625a
wachy 0.1.0-alpha.6

Do you have an idea what is going on here / what information I can provide?
The source code of the "gui" executable is here: https://github.com/xqms/imgui_ros. But I'll try to create a minimal example that triggers this problem.

@xqms
Copy link
Author

xqms commented Apr 7, 2022

Ah, maybe this is triggered when a function outside of the executable itself (e.g. shared library) is called?

@viveksjain
Copy link
Contributor

viveksjain commented Apr 7, 2022

For x it shouldn't matter whether the call is to a shared lib or not, we are just instrumenting the call instruction itself in the original function. It looks like bpftrace is interpreting the probe uprobe:...:main as referring to function _ZZ4mainENKUlvE_clEv which is

$ echo _ZZ4mainENKUlvE_clEv | c++filt
main::{lambda()#1}::operator()() const

Definitely not the same. Is the binary something that you can share? That would make it easiest to repro, otherwise I can also try to cook up the same error independently.

@viveksjain
Copy link
Contributor

Never mind I see what the issue is. I don't see an option in bpftrace to disable this though, will open an upstream bug. As a workaround, the easiest option at this point is to just not use x in main (if you can move the code you're interested in, or even the whole body of main, to a new function it should work).

@xqms
Copy link
Author

xqms commented Apr 7, 2022

Ah ok, thank you ;)

If you need a repro case for the bpftrace bug:

#include <cstdio>

int main(int argc, char** argv)
{
    auto lambda = [](int i){
        printf("YES: %d\n", i);
    };

    for(int i = 0; i < 100; ++i)
        lambda(i);
    
    return 0;
}

compiled with g++ -g -std=c++17 -o test test.cpp exhibits the same bug (press x on the lambda(i) line).

@viveksjain viveksjain added the upstream Waiting on an external dependency to be fixed first label Apr 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
upstream Waiting on an external dependency to be fixed first
Projects
None yet
Development

No branches or pull requests

2 participants