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

[#1279 4/4] Generate core dump in libscope.so #1299

Merged
merged 1 commit into from
Jan 31, 2023

Conversation

michalbiesek
Copy link
Contributor

@michalbiesek michalbiesek commented Jan 31, 2023

This Pull request required merging the following Pull Requests:

In this Pull Request following changes are introduced:

  • extending the possible values of SCOPE_ERROR_SIGNAL_HANDLER
  • generates the coredump in signal handler based on coredump or full value
  • core dump will be generated in /tmp/scope_core.<PID> path

@michalbiesek michalbiesek requested a review from jrcheli January 31, 2023 08:43
@michalbiesek michalbiesek linked an issue Jan 31, 2023 that may be closed by this pull request
- extend the possible values with core dump case

Closes #1279
@michalbiesek michalbiesek force-pushed the feat-1279-coredumper-scope-lib branch from c34c490 to da19197 Compare January 31, 2023 18:44
@michalbiesek
Copy link
Contributor Author

michalbiesek commented Jan 31, 2023

@jrcheli
This is last series of patch, to test it what You can do:

# checkout this branch
git fetch origin
git checkout origin/feat-1279-coredumper-scope-lib -b local_test
# build AppScope
# Start scoping a process (preferably on Your host machine)
sudo SCOPE_ERROR_SIGNAL_HANDLER=full ./bin/linux/x86_64/scope attach --userconfig ./conf/scope.yml <process_name>
# send SIGSEGV signal to the scoped process
kill -SIGSEGV <PID_of_scoped_process>
# the coredump should be available in '/tmp/scope_core.<pid>'
#To run core dump analysis
gdb /usr/bin/redis-server /tmp/scope.<pid>
You should be able at least see information about stack trace using bt

Note: this only works on glibc based distro

Example (redis):
On first terminal

redis-server -p 6780

On second terminal

# 8121124 is redis PID
sudo SCOPE_ERROR_SIGNAL_HANDLER=full ./bin/linux/x86_64/scope attach --userconfig ./conf/scope.yml 812124
sudo kill -SIGSEGV 812124
gdb /usr/bin/redis-server  /tmp/scope_core.812124

@jrcheli
Copy link
Contributor

jrcheli commented Jan 31, 2023

Looks great. I verified that signals (here SIGFPE) generated within a scoped process works well too...

// gcc -g -o backtrace backtrace.c

#include <stdio.h>
#include <unistd.h>

int
main(void)
{
    printf("Running backtrace\n");
    sleep (5);
    int a = 1;
    int b = 0;
    float val = a/b;

    printf("Exiting backtrace\n");
    return 0;
}

When ran LD_PRELOAD=libscope.so SCOPE_ERROR_SIGNAL_HANDLER=full ./backtrace, I saw nice stacktrace output in /tmp/scope.log, and a perfectly useable core file ( /tmp/scope. ). Everything here works as advertised. Merging!

@jrcheli jrcheli merged commit 2f3cbd3 into release/1.3 Jan 31, 2023
@jrcheli jrcheli deleted the feat-1279-coredumper-scope-lib branch January 31, 2023 20:40
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.

Coredump possibilities in AppScope
2 participants