pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Make our usage of memset_s() conform strictly to the C11 standar
6+ messages / 1 participants
[nested] [flat]

* pgsql: Make our usage of memset_s() conform strictly to the C11 standar
@ 2025-05-18 16:46 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2025-05-18 16:46 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Make our usage of memset_s() conform strictly to the C11 standard.

Per the letter of the C11 standard, one must #define
__STDC_WANT_LIB_EXT1__ as 1 before including <string.h> in order to
have access to memset_s().  It appears that many platforms are lenient
about this, because we weren't doing it and yet the code appeared to
work anyway.  But we now find that with -std=c11, macOS is strict and
doesn't declare memset_s, leading to compile failures since we try to
use it anyway.  (Given the lack of prior reports, perhaps this is new
behavior in the latest SDK?  No matter, we're clearly in the wrong.)

In addition to the immediate problem, which could be fixed merely by
adding the needed #define to explicit_bzero.c, it seems possible that
our configure-time probe for memset_s() could fail in case a platform
implements the function in some odd way due to this spec requirement.
This concern can be fixed in largely the same way that we dealt with
strchrnul() in 6da2ba1d8: switch to using a declaration-based
configure probe instead of a does-it-link probe.

Back-patch to v13 where we started using memset_s().

Reported-by: Lakshmi Narayana Velayudam <dev.narayana.v@gmail.com>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAA4pTnLcKGG78xeOjiBr5yS7ZeE-Rh=FaFQQGOO=nPzA1L8yEA@mail.gmail.com
Backpatch-through: 13

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/12eee85e511ff8854ac61e8caad8cec218b20513

Modified Files
--------------
configure                  | 15 ++++++++++++++-
configure.ac               |  3 ++-
meson.build                | 14 ++++++++------
src/include/pg_config.h.in |  7 ++++---
src/port/explicit_bzero.c  |  4 +++-
5 files changed, 31 insertions(+), 12 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Make our usage of memset_s() conform strictly to the C11 standar
@ 2025-05-18 16:46 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2025-05-18 16:46 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Make our usage of memset_s() conform strictly to the C11 standard.

Per the letter of the C11 standard, one must #define
__STDC_WANT_LIB_EXT1__ as 1 before including <string.h> in order to
have access to memset_s().  It appears that many platforms are lenient
about this, because we weren't doing it and yet the code appeared to
work anyway.  But we now find that with -std=c11, macOS is strict and
doesn't declare memset_s, leading to compile failures since we try to
use it anyway.  (Given the lack of prior reports, perhaps this is new
behavior in the latest SDK?  No matter, we're clearly in the wrong.)

In addition to the immediate problem, which could be fixed merely by
adding the needed #define to explicit_bzero.c, it seems possible that
our configure-time probe for memset_s() could fail in case a platform
implements the function in some odd way due to this spec requirement.
This concern can be fixed in largely the same way that we dealt with
strchrnul() in 6da2ba1d8: switch to using a declaration-based
configure probe instead of a does-it-link probe.

Back-patch to v13 where we started using memset_s().

Reported-by: Lakshmi Narayana Velayudam <dev.narayana.v@gmail.com>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAA4pTnLcKGG78xeOjiBr5yS7ZeE-Rh=FaFQQGOO=nPzA1L8yEA@mail.gmail.com
Backpatch-through: 13

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/5355a2400e847b1a7e7a3d9eea9516588d0fad91

Modified Files
--------------
configure                  | 15 ++++++++++++++-
configure.ac               |  3 ++-
meson.build                | 14 ++++++++------
src/include/pg_config.h.in |  7 ++++---
src/port/explicit_bzero.c  |  4 +++-
5 files changed, 31 insertions(+), 12 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Make our usage of memset_s() conform strictly to the C11 standar
@ 2025-05-18 16:46 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2025-05-18 16:46 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Make our usage of memset_s() conform strictly to the C11 standard.

Per the letter of the C11 standard, one must #define
__STDC_WANT_LIB_EXT1__ as 1 before including <string.h> in order to
have access to memset_s().  It appears that many platforms are lenient
about this, because we weren't doing it and yet the code appeared to
work anyway.  But we now find that with -std=c11, macOS is strict and
doesn't declare memset_s, leading to compile failures since we try to
use it anyway.  (Given the lack of prior reports, perhaps this is new
behavior in the latest SDK?  No matter, we're clearly in the wrong.)

In addition to the immediate problem, which could be fixed merely by
adding the needed #define to explicit_bzero.c, it seems possible that
our configure-time probe for memset_s() could fail in case a platform
implements the function in some odd way due to this spec requirement.
This concern can be fixed in largely the same way that we dealt with
strchrnul() in 6da2ba1d8: switch to using a declaration-based
configure probe instead of a does-it-link probe.

Back-patch to v13 where we started using memset_s().

Reported-by: Lakshmi Narayana Velayudam <dev.narayana.v@gmail.com>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAA4pTnLcKGG78xeOjiBr5yS7ZeE-Rh=FaFQQGOO=nPzA1L8yEA@mail.gmail.com
Backpatch-through: 13

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/253cf661c2260886f261dff0e6b8df41781da8fe

Modified Files
--------------
configure                  | 15 ++++++++++++++-
configure.ac               |  3 ++-
meson.build                | 14 ++++++++------
src/include/pg_config.h.in |  7 ++++---
src/port/explicit_bzero.c  |  4 +++-
5 files changed, 31 insertions(+), 12 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Make our usage of memset_s() conform strictly to the C11 standar
@ 2025-05-18 16:46 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2025-05-18 16:46 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Make our usage of memset_s() conform strictly to the C11 standard.

Per the letter of the C11 standard, one must #define
__STDC_WANT_LIB_EXT1__ as 1 before including <string.h> in order to
have access to memset_s().  It appears that many platforms are lenient
about this, because we weren't doing it and yet the code appeared to
work anyway.  But we now find that with -std=c11, macOS is strict and
doesn't declare memset_s, leading to compile failures since we try to
use it anyway.  (Given the lack of prior reports, perhaps this is new
behavior in the latest SDK?  No matter, we're clearly in the wrong.)

In addition to the immediate problem, which could be fixed merely by
adding the needed #define to explicit_bzero.c, it seems possible that
our configure-time probe for memset_s() could fail in case a platform
implements the function in some odd way due to this spec requirement.
This concern can be fixed in largely the same way that we dealt with
strchrnul() in 6da2ba1d8: switch to using a declaration-based
configure probe instead of a does-it-link probe.

Back-patch to v13 where we started using memset_s().

Reported-by: Lakshmi Narayana Velayudam <dev.narayana.v@gmail.com>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAA4pTnLcKGG78xeOjiBr5yS7ZeE-Rh=FaFQQGOO=nPzA1L8yEA@mail.gmail.com
Backpatch-through: 13

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/00652b3c9fb7bf2122bb076d63b15bc65e12ff71

Modified Files
--------------
configure                  | 15 ++++++++++++++-
configure.ac               |  3 ++-
src/include/pg_config.h.in |  7 ++++---
src/port/explicit_bzero.c  |  4 +++-
src/tools/msvc/Solution.pm |  2 +-
5 files changed, 24 insertions(+), 7 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Make our usage of memset_s() conform strictly to the C11 standar
@ 2025-05-18 16:46 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2025-05-18 16:46 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Make our usage of memset_s() conform strictly to the C11 standard.

Per the letter of the C11 standard, one must #define
__STDC_WANT_LIB_EXT1__ as 1 before including <string.h> in order to
have access to memset_s().  It appears that many platforms are lenient
about this, because we weren't doing it and yet the code appeared to
work anyway.  But we now find that with -std=c11, macOS is strict and
doesn't declare memset_s, leading to compile failures since we try to
use it anyway.  (Given the lack of prior reports, perhaps this is new
behavior in the latest SDK?  No matter, we're clearly in the wrong.)

In addition to the immediate problem, which could be fixed merely by
adding the needed #define to explicit_bzero.c, it seems possible that
our configure-time probe for memset_s() could fail in case a platform
implements the function in some odd way due to this spec requirement.
This concern can be fixed in largely the same way that we dealt with
strchrnul() in 6da2ba1d8: switch to using a declaration-based
configure probe instead of a does-it-link probe.

Back-patch to v13 where we started using memset_s().

Reported-by: Lakshmi Narayana Velayudam <dev.narayana.v@gmail.com>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAA4pTnLcKGG78xeOjiBr5yS7ZeE-Rh=FaFQQGOO=nPzA1L8yEA@mail.gmail.com
Backpatch-through: 13

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/a1e0e7076585323270681dc9a4f9e1272f24db68

Modified Files
--------------
configure                  | 15 ++++++++++++++-
configure.ac               |  3 ++-
src/include/pg_config.h.in |  7 ++++---
src/port/explicit_bzero.c  |  4 +++-
src/tools/msvc/Solution.pm |  2 +-
5 files changed, 24 insertions(+), 7 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* pgsql: Make our usage of memset_s() conform strictly to the C11 standar
@ 2025-05-18 16:46 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 6+ messages in thread

From: Tom Lane @ 2025-05-18 16:46 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Make our usage of memset_s() conform strictly to the C11 standard.

Per the letter of the C11 standard, one must #define
__STDC_WANT_LIB_EXT1__ as 1 before including <string.h> in order to
have access to memset_s().  It appears that many platforms are lenient
about this, because we weren't doing it and yet the code appeared to
work anyway.  But we now find that with -std=c11, macOS is strict and
doesn't declare memset_s, leading to compile failures since we try to
use it anyway.  (Given the lack of prior reports, perhaps this is new
behavior in the latest SDK?  No matter, we're clearly in the wrong.)

In addition to the immediate problem, which could be fixed merely by
adding the needed #define to explicit_bzero.c, it seems possible that
our configure-time probe for memset_s() could fail in case a platform
implements the function in some odd way due to this spec requirement.
This concern can be fixed in largely the same way that we dealt with
strchrnul() in 6da2ba1d8: switch to using a declaration-based
configure probe instead of a does-it-link probe.

Back-patch to v13 where we started using memset_s().

Reported-by: Lakshmi Narayana Velayudam <dev.narayana.v@gmail.com>
Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/CAA4pTnLcKGG78xeOjiBr5yS7ZeE-Rh=FaFQQGOO=nPzA1L8yEA@mail.gmail.com
Backpatch-through: 13

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/9bc2d37ccaab206c9140b06b535280ed82e9fe49

Modified Files
--------------
configure                  | 15 ++++++++++++++-
configure.in               |  3 ++-
src/include/pg_config.h.in |  7 ++++---
src/port/explicit_bzero.c  |  4 +++-
src/tools/msvc/Solution.pm |  2 +-
5 files changed, 24 insertions(+), 7 deletions(-)



^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2025-05-18 16:46 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-05-18 16:46 pgsql: Make our usage of memset_s() conform strictly to the C11 standar Tom Lane <tgl@sss.pgh.pa.us>
2025-05-18 16:46 pgsql: Make our usage of memset_s() conform strictly to the C11 standar Tom Lane <tgl@sss.pgh.pa.us>
2025-05-18 16:46 pgsql: Make our usage of memset_s() conform strictly to the C11 standar Tom Lane <tgl@sss.pgh.pa.us>
2025-05-18 16:46 pgsql: Make our usage of memset_s() conform strictly to the C11 standar Tom Lane <tgl@sss.pgh.pa.us>
2025-05-18 16:46 pgsql: Make our usage of memset_s() conform strictly to the C11 standar Tom Lane <tgl@sss.pgh.pa.us>
2025-05-18 16:46 pgsql: Make our usage of memset_s() conform strictly to the C11 standar Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox