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

thread '<unnamed>' panicked at 'failed to initialize perf_event_open #5

Closed
perheld opened this issue May 19, 2019 · 2 comments
Closed

Comments

@perheld
Copy link

perheld commented May 19, 2019

Hi! I made a simple program to try this out with the downloadable binaries for 0.1.0 but I ended up with this on my ubuntu 19.04 x86_64 machine:

$ RUST_BACKTRACE=1 LD_PRELOAD=./libmemory_profiler.so ./memleak
thread '' panicked at 'failed to initialize perf_event_open: Os { code: 1, kind: PermissionDenied, message: "Operation not permitted" }', src/libcore/result.rs:999:5
stack backtrace:
0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
1: std::panicking::default_hook::{{closure}}
at src/libstd/sys_common/backtrace.rs:71
at src/libstd/sys_common/backtrace.rs:59
at src/libstd/panicking.rs:197
2: std::panicking::rust_panic_with_hook
at src/libstd/panicking.rs:211
at src/libstd/panicking.rs:474
3: std::panicking::continue_panic_fmt
at src/libstd/panicking.rs:381
4: rust_begin_unwind
at src/libstd/panicking.rs:308
5: core::panicking::panic_fmt
at src/libcore/panicking.rs:85
6: core::result::unwrap_failed
at /rustc/00859e3e653973120006aaf3227823062dde1ba7/src/libcore/macros.rs:18
7: std::sync::once::Once::call_once::{{closure}}
at /rustc/00859e3e653973120006aaf3227823062dde1ba7/src/libcore/result.rs:827
at preload/src/unwind.rs:108
at /rustc/00859e3e653973120006aaf3227823062dde1ba7/src/libcore/ops/function.rs:231
at /home/travis/.cargo/registry/src/github.com-1ecc6299db9ec823/lazy_static-1.3.0/src/inline_lazy.rs:28
at /rustc/00859e3e653973120006aaf3227823062dde1ba7/src/libstd/sync/once.rs:220
8: std::sync::once::Once::call_inner
at src/libstd/sync/once.rs:387
9: memory_profiler::unwind::grab
at /rustc/00859e3e653973120006aaf3227823062dde1ba7/src/libstd/sync/once.rs:220
at /home/travis/.cargo/registry/src/github.com-1ecc6299db9ec823/lazy_static-1.3.0/src/inline_lazy.rs:27
at /home/travis/build/nokia/memory-profiler/<::lazy_static::__lazy_static_internal macros>:12
at /home/travis/build/nokia/memory-profiler/<::lazy_static::__lazy_static_internal macros>:13
at preload/src/unwind.rs:132
10: malloc
at preload/src/lib.rs:1423
at preload/src/lib.rs:1459
11:
12:
13:
14:
Aborted (core dumped)

My simple program which I made for the test purpose:
`
#include <stdio.h>
#include <malloc.h>
int main()
{
printf("lets leak some memory\n");

    while (1) {
            char *p = malloc(1024);
            sleep(1);
    }

    return 0;

}
`

@koute
Copy link
Owner

koute commented May 19, 2019

Are you running this on bare metal or under Docker?

The profiler needs the permissions to call perf_event_open on itself so that it can be notified when new shared objects are loaded. (If anyone knows a better way of doing this I'd be great to know.)

You can adjust the permissions by modifying /proc/sys/kernel/perf_event_paranoid, e.g. if you do this:

echo "-1" | sudo tee /proc/sys/kernel/perf_event_paranoid

then it should work. (Although it should also work with the default value of 2.) You can also set the CAP_SYS_ADMIN capability if you're running this under Docker.

@koute
Copy link
Owner

koute commented Oct 7, 2019

Fixed in 0.5.0.

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

No branches or pull requests

2 participants