[ovs-dev] [PATCH] fatal-signal: Remove snprintf.
Ben Pfaff
blp at ovn.org
Wed Mar 25 15:38:53 UTC 2020
On Wed, Mar 25, 2020 at 07:34:13AM -0700, William Tu wrote:
> Function snprintf is not async-signal-safe. Replace it with
> our own implementation. Example ovs-vswitchd.log output:
> 2020-03-25T01:08:19.673Z|00050|memory|INFO|handlers:2 ports:3
> SIGSEGV detected, backtrace:
> 0x4872d9 <fatal_signal_handler+0x49>
> 0x7f4e2ab974b0 <killpg+0x40>
> 0x7f4e2ac5d74d <__poll+0x2d>
> 0x531098 <time_poll+0x108>
> 0x51aefc <poll_block+0x8c>
> 0x445ca9 <udpif_revalidator+0x289>
> 0x5056fd <ovsthread_wrapper+0x7d>
> 0x7f4e2b65f6ba <start_thread+0xca>
> 0x7f4e2ac6941d <clone+0x6d>
> 0x0 <+0x0>
>
> Tested-at: https://travis-ci.org/github/williamtu/ovs-travis/builds/666596271
> Signed-off-by: William Tu <u9012063 at gmail.com>
I didn't test this, but I assume you did.
The traditional way to get a hex digit is to write "0123456789abcdef"[x],
although your way is fine too.
If the function name is long, this will overflow the line buffer.
There's no reason to write "line =" in each of these, since strcat()
just returns its first argument.
> + line = strcat(line, "0x");
> + line = strcat(line, ip_str);
> + line = strcat(line, "<");
> + line = strcat(line, unw_bt[i].func);
> + line = strcat(line, "+0x");
> + line = strcat(line, offset_str);
> + line = strcat(line, ">\n");
More information about the dev
mailing list