Bruno Haible <[email protected]> writes:

> Collin Funk wrote:
>> > The reason is that realloc (p, size) sets errno when failing only when
>> > size <= 0x700000000000000; it leaves errno untouched if
>> > size > 0x700000000000000.
>> >
>> > This patch provides a workaround.
>> >
>> > Collin, if you want to send a bug report to the FreeBSD people, here's
>> > my test program:
>> > =========================== foo.c ===========================
>> > #include <errno.h>
>> > #include <stdint.h>
>> > #include <stdio.h>
>> > #include <stdlib.h>
>> > int main (int argc, char *argv[])
>> > {
>> >   size_t b = (argc > 1 ? atol (argv[1]) : PTRDIFF_MAX + 1);
>> >   errno = 1729;
>> >   void *p = malloc (1);
>> >   printf ("p = 0x%lx, errno = %d\n", (unsigned long) p, errno);
>> >   p = realloc (p, b);
>> >   printf ("p = 0x%lx, errno = %d\n", (unsigned long) p, errno);
>> > }
>> > ===============================================================
>> 
>> Sure, I can report it. Thanks.
>> 
>> Whether it will be fixed or not I am unsure.
>
> Did they give you any feedback on this one?

I wanted to get a FreeBSD 14.3 VM to make sure the bug report was easy
for them to reproduce and compare to FreeBSD 15.0's regression. I
obviously got a bit lazy and did not get around to it.

I reported that now [1]. They seem to get around to fixing things
quickly.

In the meantime, I pushed the attached patch linking the the report in a
comment.

Collin

[1] https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=291677

>From cec6e1a9295e7b05a09d76e03ce34f8a11f8b40e Mon Sep 17 00:00:00 2001
Message-ID: <cec6e1a9295e7b05a09d76e03ce34f8a11f8b40e.1765764957.git.collin.fu...@gmail.com>
From: Collin Funk <[email protected]>
Date: Sun, 14 Dec 2025 18:12:02 -0800
Subject: [PATCH] doc: Add a link to a FreeBSD bug report.

* doc/posix-functions/realloc.texi: Add a link to the bug report for
FreeBSD 15 not setting errno for large size values.
---
 ChangeLog                        | 6 ++++++
 doc/posix-functions/realloc.texi | 1 +
 2 files changed, 7 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index e5e67e7a8c..b8954e4040 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2025-12-14  Collin Funk  <[email protected]>
+
+	doc: Add a link to a FreeBSD bug report.
+	* doc/posix-functions/realloc.texi: Add a link to the bug report for
+	FreeBSD 15 not setting errno for large size values.
+
 2025-12-12  Paul Eggert  <[email protected]>
 
 	extern-inline: #define AAA_INLINE pre-<config.h>
diff --git a/doc/posix-functions/realloc.texi b/doc/posix-functions/realloc.texi
index 5a0feb8521..fae8b65a96 100644
--- a/doc/posix-functions/realloc.texi
+++ b/doc/posix-functions/realloc.texi
@@ -12,6 +12,7 @@ @node realloc
 @itemize
 @item
 On some platforms, when the function fails it does not set @code{errno}:
+@c https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=291677
 FreeBSD 15 (for a size > 0x7000000000000000), mingw, MSVC 14.
 
 @item
-- 
2.52.0

Reply via email to