POSIX does not allow "tv" to be NULL. On glibc and gnulib calling gettimeofday(NULL, NULL) can segfault. For glibc see __gettimeofday() and __gettimeofday64() in sysdeps/unix/sysv/linux/gettimeofday.c. Note that by default glibc may use the gettimeofday() syscall or vdso function which both support "tv" to be NULL. The segfault can be triggered by compiling a i386 binary on a x86_64 system. Signed-off-by: Thomas Weißschuh <thomas@xxxxxxxx> --- man2/gettimeofday.2 | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/man2/gettimeofday.2 b/man2/gettimeofday.2 index 9d134fa49de7..cdbec5ede23c 100644 --- a/man2/gettimeofday.2 +++ b/man2/gettimeofday.2 @@ -85,16 +85,14 @@ struct timezone { .EE .in .PP -If either -.I tv -or +If .I tz -is NULL, the corresponding structure is not set or returned. +is NULL, the structure is not set or returned. .\" FIXME . The compilation warning looks to be going away in glibc 2.17 .\" see glibc commit 4b7634a5e03b0da6f8875de9d3f74c1cf6f2a6e8 -(However, compilation warnings will result if +If .I tv -is NULL.) +is NULL, the behavior is unspecified. .\" The following is covered under EPERM below: .\" .PP .\" Only the superuser may use --- base-commit: f0067f73941ea0e512b9018a123472508a0858db change-id: 20230530-gettimeofday-null-7ee404b7825f Best regards, -- Thomas Weißschuh <thomas@xxxxxxxx>