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

Martin Kletzander mkletzan at redhat.com
Tue May 20 09:20:20 UTC 2014


On Tue, May 20, 2014 at 10:05:19AM +0100, Daniel P. Berrange wrote:
>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.
>

And if you can't (or don't want to) have abrt then it is pretty easy
to make a self-created solution using kernel.core_pattern in
/etc/sysctl.conf

>Regards,
>Daniel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140520/fa7e9aeb/attachment-0001.sig>


More information about the libvir-list mailing list