[ovs-dev] [PATCH] Remove "fault" module.

Justin Pettit jpettit at nicira.com
Thu Jan 7 00:06:06 UTC 2010


Since I write flawless code, I've never used this feature.  Go ahead and get rid of it, because it reminds me of the stink of others' failures.

--Justin


On Dec 21, 2009, at 4:40 PM, Ben Pfaff wrote:

> This module, which catches segmentation faults and prints a backtrace
> before exiting, was useful for a while, but I believe that it has now
> outlived its purpose.  It is altogether better to have a core dump from
> which one can extract much more information than a usually-poor backtrace,
> and core dumps are much better integrated into a typical Unix system.
> In addition, the "fault" module was of course not all that portable.
> ---
> configure.ac               |    1 -
> lib/automake.mk            |    2 -
> lib/fault.c                |   73 --------------------------------------------
> lib/fault.h                |   23 --------------
> lib/vlog-modules.def       |    1 -
> m4/openvswitch.m4          |    5 ---
> ovsdb/automake.mk          |    2 +-
> ovsdb/ovsdb-server.c       |    2 -
> tests/automake.mk          |    2 +-
> tests/test-dhcp-client.c   |    2 -
> utilities/automake.mk      |    9 ++---
> utilities/ovs-controller.c |    2 -
> utilities/ovs-openflowd.c  |    2 -
> vswitchd/automake.mk       |    5 +--
> vswitchd/ovs-brcompatd.c   |    2 -
> vswitchd/ovs-vswitchd.c    |    2 -
> 16 files changed, 7 insertions(+), 128 deletions(-)
> delete mode 100644 lib/fault.c
> delete mode 100644 lib/fault.h
> 
> diff --git a/configure.ac b/configure.ac
> index a94ff93..92d5ac0 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -58,7 +58,6 @@ OVS_CHECK_MALLOC_HOOKS
> OVS_CHECK_VALGRIND
> OVS_CHECK_TTY_LOCK_DIR
> OVS_CHECK_SOCKET_LIBS
> -OVS_CHECK_FAULT_LIBS
> 
> AC_CHECK_FUNCS([strsignal])
> 
> diff --git a/lib/automake.mk b/lib/automake.mk
> index cace97c..a9c7ed2 100644
> --- a/lib/automake.mk
> +++ b/lib/automake.mk
> @@ -45,8 +45,6 @@ lib_libopenvswitch_a_SOURCES = \
> 	lib/dynamic-string.h \
> 	lib/fatal-signal.c \
> 	lib/fatal-signal.h \
> -	lib/fault.c \
> -	lib/fault.h \
> 	lib/flow.c \
> 	lib/flow.h \
> 	lib/hash.c \
> diff --git a/lib/fault.c b/lib/fault.c
> deleted file mode 100644
> index 14e229e..0000000
> --- a/lib/fault.c
> +++ /dev/null
> @@ -1,73 +0,0 @@
> -/*
> - * Copyright (c) 2008, 2009 Nicira Networks.
> - *
> - * Licensed under the Apache License, Version 2.0 (the "License");
> - * you may not use this file except in compliance with the License.
> - * You may obtain a copy of the License at:
> - *
> - *     http://www.apache.org/licenses/LICENSE-2.0
> - *
> - * Unless required by applicable law or agreed to in writing, software
> - * distributed under the License is distributed on an "AS IS" BASIS,
> - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> - * See the License for the specific language governing permissions and
> - * limitations under the License.
> - */
> -
> -#include <config.h>
> -#include "fault.h"
> -#include <dlfcn.h>
> -#include <inttypes.h>
> -#include <stdio.h>
> -#include <stdlib.h>
> -#include <string.h>
> -#include <signal.h>
> -#include "util.h"
> -
> -#include "vlog.h"
> -#define THIS_MODULE VLM_fault
> -
> -static void
> -fault_handler(int sig_nr)
> -{
> -    VLOG_EMER("Caught signal %d.", sig_nr);
> -    log_backtrace();
> -    fflush(stdout);
> -    fflush(stderr);
> -
> -    signal(sig_nr, SIG_DFL);
> -    raise(sig_nr);
> -}
> -
> -void
> -log_backtrace(void)
> -{
> -    /* During the loop:
> -
> -       frame[0] points to the next frame.
> -       frame[1] points to the return address. */
> -    void **frame;
> -    for (frame = __builtin_frame_address(0);
> -         frame != NULL && frame[0] != NULL;
> -         frame = frame[0]) {
> -        Dl_info addrinfo;
> -        if (!dladdr(frame[1], &addrinfo) || !addrinfo.dli_sname) {
> -            fprintf(stderr, "  0x%08"PRIxPTR"\n", (uintptr_t) frame[1]);
> -        } else {
> -            fprintf(stderr, "  0x%08"PRIxPTR" (%s+0x%tx)\n",
> -                    (uintptr_t) frame[1], addrinfo.dli_sname,
> -                    (char *) frame[1] - (char *) addrinfo.dli_saddr); 
> -        }
> -    }
> -    fflush(stderr);
> -}
> -
> -void
> -register_fault_handlers(void)
> -{
> -    signal(SIGABRT, fault_handler);
> -    signal(SIGBUS, fault_handler);
> -    signal(SIGFPE, fault_handler);
> -    signal(SIGILL, fault_handler);
> -    signal(SIGSEGV, fault_handler);
> -}
> diff --git a/lib/fault.h b/lib/fault.h
> deleted file mode 100644
> index 0d12927..0000000
> --- a/lib/fault.h
> +++ /dev/null
> @@ -1,23 +0,0 @@
> -/*
> - * Copyright (c) 2008 Nicira Networks.
> - *
> - * Licensed under the Apache License, Version 2.0 (the "License");
> - * you may not use this file except in compliance with the License.
> - * You may obtain a copy of the License at:
> - *
> - *     http://www.apache.org/licenses/LICENSE-2.0
> - *
> - * Unless required by applicable law or agreed to in writing, software
> - * distributed under the License is distributed on an "AS IS" BASIS,
> - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> - * See the License for the specific language governing permissions and
> - * limitations under the License.
> - */
> -
> -#ifndef FAULT_H
> -#define FAULT_H 1
> -
> -void register_fault_handlers(void);
> -void log_backtrace(void);
> -
> -#endif /* fault.h */
> diff --git a/lib/vlog-modules.def b/lib/vlog-modules.def
> index 3a4f92a..023190a 100644
> --- a/lib/vlog-modules.def
> +++ b/lib/vlog-modules.def
> @@ -38,7 +38,6 @@ VLOG_MODULE(executer)
> VLOG_MODULE(ezio_term)
> VLOG_MODULE(fail_open)
> VLOG_MODULE(fatal_signal)
> -VLOG_MODULE(fault)
> VLOG_MODULE(flow)
> VLOG_MODULE(in_band)
> VLOG_MODULE(jsonrpc)
> diff --git a/m4/openvswitch.m4 b/m4/openvswitch.m4
> index ceb1073..f9b7e57 100644
> --- a/m4/openvswitch.m4
> +++ b/m4/openvswitch.m4
> @@ -98,11 +98,6 @@ AC_DEFUN([OVS_CHECK_OPENSSL],
>       AC_DEFINE([HAVE_OPENSSL], [1], [Define to 1 if OpenSSL is installed.])
>    fi])
> 
> -dnl Checks for libraries needed by lib/fault.c.
> -AC_DEFUN([OVS_CHECK_FAULT_LIBS],
> -  [AC_CHECK_LIB([dl], [dladdr], [FAULT_LIBS=-ldl])
> -   AC_SUBST([FAULT_LIBS])])
> -
> dnl Checks for libraries needed by lib/socket-util.c.
> AC_DEFUN([OVS_CHECK_SOCKET_LIBS],
>   [AC_CHECK_LIB([socket], [connect])
> diff --git a/ovsdb/automake.mk b/ovsdb/automake.mk
> index 2732c53..0f6232e 100644
> --- a/ovsdb/automake.mk
> +++ b/ovsdb/automake.mk
> @@ -49,7 +49,7 @@ EXTRA_DIST += ovsdb/ovsdb-client.1.in
> # ovsdb-server
> sbin_PROGRAMS += ovsdb/ovsdb-server
> ovsdb_ovsdb_server_SOURCES = ovsdb/ovsdb-server.c
> -ovsdb_ovsdb_server_LDADD = ovsdb/libovsdb.a lib/libopenvswitch.a $(FAULT_LIBS)
> +ovsdb_ovsdb_server_LDADD = ovsdb/libovsdb.a lib/libopenvswitch.a
> # ovsdb-server.1
> man_MANS += ovsdb/ovsdb-server.1
> DISTCLEANFILES += ovsdb/ovsdb-server.1
> diff --git a/ovsdb/ovsdb-server.c b/ovsdb/ovsdb-server.c
> index 125001f..8f3d56a 100644
> --- a/ovsdb/ovsdb-server.c
> +++ b/ovsdb/ovsdb-server.c
> @@ -24,7 +24,6 @@
> 
> #include "command-line.h"
> #include "daemon.h"
> -#include "fault.h"
> #include "file.h"
> #include "json.h"
> #include "jsonrpc.h"
> @@ -67,7 +66,6 @@ main(int argc, char *argv[])
>     size_t i;
> 
>     set_program_name(argv[0]);
> -    register_fault_handlers();
>     time_init();
>     vlog_init();
>     signal(SIGPIPE, SIG_IGN);
> diff --git a/tests/automake.mk b/tests/automake.mk
> index 60c0393..a393a04 100644
> --- a/tests/automake.mk
> +++ b/tests/automake.mk
> @@ -135,7 +135,7 @@ tests_test_type_props_SOURCES = tests/test-type-props.c
> 
> noinst_PROGRAMS += tests/test-dhcp-client
> tests_test_dhcp_client_SOURCES = tests/test-dhcp-client.c
> -tests_test_dhcp_client_LDADD = lib/libopenvswitch.a $(FAULT_LIBS)
> +tests_test_dhcp_client_LDADD = lib/libopenvswitch.a
> 
> noinst_PROGRAMS += tests/test-stp
> tests_test_stp_SOURCES = tests/test-stp.c
> diff --git a/tests/test-dhcp-client.c b/tests/test-dhcp-client.c
> index e4471c7..24e2d41 100644
> --- a/tests/test-dhcp-client.c
> +++ b/tests/test-dhcp-client.c
> @@ -23,7 +23,6 @@
> #include "command-line.h"
> #include "dhcp.h"
> #include "fatal-signal.h"
> -#include "fault.h"
> #include "poll-loop.h"
> #include "util.h"
> #include "vlog.h"
> @@ -51,7 +50,6 @@ main(int argc, char *argv[])
>     int error;
> 
>     set_program_name(argv[0]);
> -    register_fault_handlers();
>     vlog_init();
>     parse_options(argc, argv);
> 
> diff --git a/utilities/automake.mk b/utilities/automake.mk
> index aec78b5..1ae50bf 100644
> --- a/utilities/automake.mk
> +++ b/utilities/automake.mk
> @@ -55,29 +55,28 @@ utilities_ovs_appctl_SOURCES = utilities/ovs-appctl.c
> utilities_ovs_appctl_LDADD = lib/libopenvswitch.a
> 
> utilities_ovs_controller_SOURCES = utilities/ovs-controller.c
> -utilities_ovs_controller_LDADD = lib/libopenvswitch.a $(FAULT_LIBS) $(SSL_LIBS)
> +utilities_ovs_controller_LDADD = lib/libopenvswitch.a $(SSL_LIBS)
> 
> utilities_ovs_discover_SOURCES = utilities/ovs-discover.c
> utilities_ovs_discover_LDADD = lib/libopenvswitch.a
> 
> utilities_ovs_dpctl_SOURCES = utilities/ovs-dpctl.c
> -utilities_ovs_dpctl_LDADD = lib/libopenvswitch.a $(FAULT_LIBS)
> +utilities_ovs_dpctl_LDADD = lib/libopenvswitch.a
> 
> utilities_ovs_kill_SOURCES = utilities/ovs-kill.c
> utilities_ovs_kill_LDADD = lib/libopenvswitch.a
> 
> utilities_ovs_ofctl_SOURCES = utilities/ovs-ofctl.c
> -utilities_ovs_ofctl_LDADD = lib/libopenvswitch.a $(FAULT_LIBS) $(SSL_LIBS)
> +utilities_ovs_ofctl_LDADD = lib/libopenvswitch.a $(SSL_LIBS)
> 
> utilities_ovs_openflowd_SOURCES = utilities/ovs-openflowd.c
> utilities_ovs_openflowd_LDADD = \
> 	ofproto/libofproto.a \
> 	lib/libopenvswitch.a \
> -	$(FAULT_LIBS) \
> 	$(SSL_LIBS)
> 
> utilities_ovs_vsctl_SOURCES = utilities/ovs-vsctl.c vswitchd/vswitch-idl.c
> -utilities_ovs_vsctl_LDADD = lib/libopenvswitch.a $(FAULT_LIBS)
> +utilities_ovs_vsctl_LDADD = lib/libopenvswitch.a
> 
> utilities_ovs_wdt_SOURCES = utilities/ovs-wdt.c
> 
> diff --git a/utilities/ovs-controller.c b/utilities/ovs-controller.c
> index e2816cf..f0ee87d 100644
> --- a/utilities/ovs-controller.c
> +++ b/utilities/ovs-controller.c
> @@ -26,7 +26,6 @@
> #include "command-line.h"
> #include "compiler.h"
> #include "daemon.h"
> -#include "fault.h"
> #include "learning-switch.h"
> #include "ofpbuf.h"
> #include "openflow/openflow.h"
> @@ -84,7 +83,6 @@ main(int argc, char *argv[])
>     int i;
> 
>     set_program_name(argv[0]);
> -    register_fault_handlers();
>     time_init();
>     vlog_init();
>     parse_options(argc, argv);
> diff --git a/utilities/ovs-openflowd.c b/utilities/ovs-openflowd.c
> index ba97faf..d824eba 100644
> --- a/utilities/ovs-openflowd.c
> +++ b/utilities/ovs-openflowd.c
> @@ -29,7 +29,6 @@
> #include "daemon.h"
> #include "dirs.h"
> #include "dpif.h"
> -#include "fault.h"
> #include "leak-checker.h"
> #include "list.h"
> #include "netdev.h"
> @@ -118,7 +117,6 @@ main(int argc, char *argv[])
>     struct netflow_options nf_options;
> 
>     set_program_name(argv[0]);
> -    register_fault_handlers();
>     time_init();
>     vlog_init();
>     parse_options(argc, argv, &s);
> diff --git a/vswitchd/automake.mk b/vswitchd/automake.mk
> index 29e4034..694c308 100644
> --- a/vswitchd/automake.mk
> +++ b/vswitchd/automake.mk
> @@ -19,7 +19,6 @@ vswitchd_ovs_vswitchd_SOURCES = \
> vswitchd_ovs_vswitchd_LDADD = \
> 	ofproto/libofproto.a \
> 	lib/libopenvswitch.a \
> -	$(FAULT_LIBS) \
> 	$(SSL_LIBS)
> 
> vswitchd_ovs_brcompatd_SOURCES = \
> @@ -27,9 +26,7 @@ vswitchd_ovs_brcompatd_SOURCES = \
> 	vswitchd/vswitch-idl.c \
> 	vswitchd/vswitch-idl.h
> 
> -vswitchd_ovs_brcompatd_LDADD = \
> -	lib/libopenvswitch.a \
> -	$(FAULT_LIBS) 
> +vswitchd_ovs_brcompatd_LDADD = lib/libopenvswitch.a
> 
> EXTRA_DIST += \
> 	vswitchd/ovs-vswitchd.8.in \
> diff --git a/vswitchd/ovs-brcompatd.c b/vswitchd/ovs-brcompatd.c
> index 62faaaa..594d474 100644
> --- a/vswitchd/ovs-brcompatd.c
> +++ b/vswitchd/ovs-brcompatd.c
> @@ -39,7 +39,6 @@
> #include "dirs.h"
> #include "dynamic-string.h"
> #include "fatal-signal.h"
> -#include "fault.h"
> #include "leak-checker.h"
> #include "netdev.h"
> #include "netlink.h"
> @@ -1147,7 +1146,6 @@ main(int argc, char *argv[])
>     int retval;
> 
>     set_program_name(argv[0]);
> -    register_fault_handlers();
>     time_init();
>     vlog_init();
>     vlog_set_levels(VLM_ANY_MODULE, VLF_CONSOLE, VLL_WARN);
> diff --git a/vswitchd/ovs-vswitchd.c b/vswitchd/ovs-vswitchd.c
> index 4cefc40..b699ae4 100644
> --- a/vswitchd/ovs-vswitchd.c
> +++ b/vswitchd/ovs-vswitchd.c
> @@ -28,7 +28,6 @@
> #include "compiler.h"
> #include "daemon.h"
> #include "dpif.h"
> -#include "fault.h"
> #include "leak-checker.h"
> #include "netdev.h"
> #include "ovsdb-idl.h"
> @@ -64,7 +63,6 @@ main(int argc, char *argv[])
>     int retval;
> 
>     set_program_name(argv[0]);
> -    register_fault_handlers();
>     time_init();
>     vlog_init();
>     remote = parse_options(argc, argv);
> -- 
> 1.6.3.3
> 
> 
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev_openvswitch.org





More information about the dev mailing list