Re: [PATCH] virlog: Add stack trace log when libvirt receives fatal signal

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, May 20, 2014 at 08:59:37AM +0000, Wangrui (K) wrote:
> An earlier commit(c0c8c1) Dan removed global log buffer feature entirely
> because of duplicate log messages. An improvement is introduced. That is
> dumping stack trace instead of log buffer upon libvirt crash.

While I understand the desire here...

> +virLogDumpAllFD(const char *msg, int len)
> +{
> +    size_t i;
> +    bool found = false;
> +
> +    if (len <= 0)
> +        len = strlen(msg);
> +
> +    for (i = 0; i < virLogNbOutputs; i++) {
> +        if (virLogOutputs[i].f == virLogOutputToFd) {
> +            int fd = (intptr_t) virLogOutputs[i].data;
> +
> +            if (fd >= 0) {
> +                if (msg)
> +                    ignore_value(safewrite(fd, msg, len));
> +                else
> +                    virLogStackTraceToFd(fd);
> +
> +                found = true;
> +            }
> +        }
> +    }
> +    if (!found) {
> +        if (msg)
> +            ignore_value(safewrite(STDERR_FILENO, msg, len));
> +        else
> +            virLogStackTraceToFd(STDERR_FILENO);

This is not going to work. virLogStackTraceToFd invokes the
backtrace/backtrace_symbols_fd functions which are not async
signal safe. They are also not likely to be reliable to use
when you have memory corruption triggering the signal.

The 'abrt' program is commonly used on modern Linux distros to
generate stack traces when processes crash / terminate abnormally.
abrt has the added benefit that the stack traces it records include
all function parameters and local variables.

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]