Re: Clean up some signal usage mainly related to Windows
Tristan Partin <tristan@neon.tech>
From: "Tristan Partin" <tristan@neon.tech>
To: "Nathan Bossart" <nathandbossart@gmail.com>, "Peter Eisentraut"
<peter@eisentraut.org>
Cc: <pgsql-hackers@postgresql.org>
Date: 2023-12-06T16:28:49Z
Lists: pgsql-hackers
On Wed Dec 6, 2023 at 10:18 AM CST, Nathan Bossart wrote: > On Wed, Dec 06, 2023 at 10:23:52AM +0100, Peter Eisentraut wrote: > > Ok, I have committed your 0001 patch. > > My compiler is unhappy about this one: > > ../postgresql/src/bin/pg_test_fsync/pg_test_fsync.c:605:2: error: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Werror=unused-result] > 605 | write(STDOUT_FILENO, "\n", 1); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Some glibc source: > /* If fortification mode, we warn about unused results of certain > function calls which can lead to problems. */ > #if __GNUC_PREREQ (3,4) || __glibc_has_attribute (__warn_unused_result__) > # define __attribute_warn_unused_result__ \ > __attribute__ ((__warn_unused_result__)) > # if defined __USE_FORTIFY_LEVEL && __USE_FORTIFY_LEVEL > 0 > # define __wur __attribute_warn_unused_result__ > # endif > #else > # define __attribute_warn_unused_result__ /* empty */ > #endif > #ifndef __wur > # define __wur /* Ignore */ > #endif > extern ssize_t write (int __fd, const void *__buf, size_t __n) __wur > __attr_access ((__read_only__, 2, 3)); According to my setup, I am hitting the /* Ignore */ variant of __wur. I am guessing that Fedora doesn't add fortification to the default CFLAGS. What distro are you using? But yes, something like what you proposed sounds good to me. Sorry for leaving this out! Makes me wonder if setting -D_FORTIFY_SOURCE=2 in debug builds at least would make sense, if not all builds. According to the OpenSSF[0], level 2 is only supposed to impact runtime performance by 0.1%. [0]: https://best.openssf.org/Compiler-Hardening-Guides/Compiler-Options-Hardening-Guide-for-C-and-C++.html#performance-implications -- Tristan Partin Neon (https://neon.tech)
Commits
-
Suppress -Wunused-result warning about write().
- c2a465b2c94f 17.0 landed
-
Use signal-safe functions in signal handler
- 52e98d450230 17.0 landed