From 660e0373685aa6b4bc1ddb4404e34f051e948891 Mon Sep 17 00:00:00 2001 From: "Sungjun, Kim" Date: Fri, 17 May 2019 16:42:40 +0900 Subject: [PATCH] Print necessary stackstace information when crashed --- .../mgmt_frontend/mgmt_frontend_entry.sh | 17 +++++++++++++++++ .../query_frontend/query_frontend_entry.sh | 17 +++++++++++++++++ dockerfiles/ManagementFrontendDockerfile | 6 +++++- dockerfiles/QueryFrontendDockerfile | 8 ++++++-- src/frontends/src/query_frontend_main.cpp | 19 +++++++++++++++++++ .../src/management_frontend_main.cpp | 17 +++++++++++++++++ 6 files changed, 81 insertions(+), 3 deletions(-) create mode 100755 containers/mgmt_frontend/mgmt_frontend_entry.sh create mode 100755 containers/query_frontend/query_frontend_entry.sh diff --git a/containers/mgmt_frontend/mgmt_frontend_entry.sh b/containers/mgmt_frontend/mgmt_frontend_entry.sh new file mode 100755 index 000000000..aa569a046 --- /dev/null +++ b/containers/mgmt_frontend/mgmt_frontend_entry.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env sh + +ARGS=$@ + +cmd() { + /clipper/release/src/management/management_frontend ${ARGS} +} + +ulimit -c unlimited + +cmd & pid=$! + +wait ${pid} + +RESULT=$? + +exit ${RESULT} \ No newline at end of file diff --git a/containers/query_frontend/query_frontend_entry.sh b/containers/query_frontend/query_frontend_entry.sh new file mode 100755 index 000000000..f50a61993 --- /dev/null +++ b/containers/query_frontend/query_frontend_entry.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env sh + +ARGS=$@ + +cmd() { + /clipper/release/src/frontends/query_frontend ${ARGS} +} + +ulimit -c unlimited + +cmd & pid=$! + +wait ${pid} + +RESULT=$? + +exit ${RESULT} \ No newline at end of file diff --git a/dockerfiles/ManagementFrontendDockerfile b/dockerfiles/ManagementFrontendDockerfile index 4ea5bc5c9..28e348337 100644 --- a/dockerfiles/ManagementFrontendDockerfile +++ b/dockerfiles/ManagementFrontendDockerfile @@ -14,6 +14,10 @@ RUN cd /clipper/src/libs/spdlog \ && cd release \ && make -j4 management_frontend -ENTRYPOINT ["/clipper/release/src/management/management_frontend"] +COPY containers/mgmt_frontend/mgmt_frontend_entry.sh /clipper/ + +WORKDIR /clipper/ + +ENTRYPOINT ["/clipper/mgmt_frontend_entry.sh"] # vim: set filetype=dockerfile: diff --git a/dockerfiles/QueryFrontendDockerfile b/dockerfiles/QueryFrontendDockerfile index df52e7124..a86df0c84 100644 --- a/dockerfiles/QueryFrontendDockerfile +++ b/dockerfiles/QueryFrontendDockerfile @@ -14,6 +14,10 @@ RUN cd /clipper/src/libs/spdlog \ && cd release \ && make -j4 query_frontend -ENTRYPOINT ["/clipper/release/src/frontends/query_frontend"] +COPY containers/query_frontend/query_frontend_entry.sh /clipper/ -# vim: set filetype=dockerfile: +WORKDIR /clipper/ + +ENTRYPOINT ["/clipper/query_frontend_entry.sh"] + +# vim: set filetype=dockerfile: \ No newline at end of file diff --git a/src/frontends/src/query_frontend_main.cpp b/src/frontends/src/query_frontend_main.cpp index b6e4708d9..9530fb102 100644 --- a/src/frontends/src/query_frontend_main.cpp +++ b/src/frontends/src/query_frontend_main.cpp @@ -1,3 +1,7 @@ + +#include +#include + #include #include #include @@ -5,7 +9,22 @@ #include "query_frontend.hpp" +void handler(int sig) { + void *array[10]; + size_t size; + + // get void*'s for all entries on the stack + size = backtrace(array, 10); + + // print out all the frames to stderr + fprintf(stderr, "Error: signal %d:\n", sig); + backtrace_symbols_fd(array, size, STDERR_FILENO); + exit(1); +} + int main(int argc, char* argv[]) { + signal(SIGSEGV, handler); + cxxopts::Options options("query_frontend", "Clipper query processing frontend"); // clang-format off diff --git a/src/management/src/management_frontend_main.cpp b/src/management/src/management_frontend_main.cpp index 261b6a3d6..967a07d4a 100644 --- a/src/management/src/management_frontend_main.cpp +++ b/src/management/src/management_frontend_main.cpp @@ -1,4 +1,6 @@ +#include +#include #include #include @@ -6,7 +8,22 @@ #include "management_frontend.hpp" +void handler(int sig) { + void *array[10]; + size_t size; + + // get void*'s for all entries on the stack + size = backtrace(array, 10); + + // print out all the frames to stderr + fprintf(stderr, "Error: signal %d:\n", sig); + backtrace_symbols_fd(array, size, STDERR_FILENO); + exit(1); +} + int main(int argc, char* argv[]) { + signal(SIGSEGV, handler); + cxxopts::Options options("management_frontend", "Clipper management interface");