Skip to content

Segfault in perf system when start and end time is the same #101

Closed

Description

Describe the bug
The call to _jbpf_perf_log() can lead to segfaults if the start_time and end_time passed are the same.

To Reproduce
Sample code that can trigger the segfault:

#include "jbpf.h"
#include "jbpf_perf.h"

int
main(int argc, char* argv[])
{
    struct jbpf_config config = {0};
    uint32_t perf_idx;
    struct jbpf_hook test_hook = {
        .name = "test_hook",
        .hook_type = JBPF_HOOK_TYPE_MON,
        .jbpf_perf_active = JBPF_HOOK_PERF_DEFAULT_STATE,
    };

    jbpf_set_default_config_options(&config);
    jbpf_init_perf_hook(&test_hook);
    jbpf_register_thread();

    perf_idx = get_jbpf_hook_thread_id();

    struct jbpf_perf_data* perf_data = jbpf_get_perf_data(&test_hook);
    uint64_t invalid_start_time = 12345;
    uint64_t invalid_end_time = 12345;
    res = _jbpf_perf_log(perf_data, invalid_start_time, invalid_end_time);
    jbpf_stop();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions