[bug #67424] Allocate the message buffer for $(info ...) on the heap instead of stack.

anonymous <[email protected]> Wed, 13 Aug 2025 10:42:08 -0400 (EDT)
Newsgroups gmane.comp.gnu.make.bugs
Message-ID <[email protected]>
URL:
  <https://savannah.gnu.org/bugs/?67424>

                 Summary: Allocate the message buffer for $(info ...) on the
heap instead of stack.
                   Group: make
               Submitter: None
               Submitted: Wed 13 Aug 2025 02:42:04 PM UTC
                Severity: 3 - Normal
              Item Group: Enhancement
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
       Component Version: 4.4.1
        Operating System: POSIX-Based
           Fixed Release: None
           Triage Status: None


    _______________________________________________________

Follow-up Comments:


-------------------------------------------------------
Date: Wed 13 Aug 2025 02:42:04 PM UTC By: Anonymous
I tried to benchmark make and created a variable with a very long content
(64MiB).

To check how long the variable actually is I output the variable with the
$(info ...) and piped it through "wc".

This results in a "Segmentation Fault" on my system.

The reason is, that the $(info ...) function allocates the memory for the
output on the stack.
Outputting a (very) long string then overflows the stack.

I attach a small patch against make 4.4.1 which lets $(info ...) allocate the
buffer on the heap instead of the stack, which avoids the stack overflow.







    _______________________________________________________
File Attachments:

Name: 0001-Allocate-output-of-info-.-function-on-heap-instead-o.patch Size:
1017B

<https://file.savannah.gnu.org/file/0001-Allocate-output-of-info-.-function-on-heap-instead-o.patch?file_id=57528>



    AGPL NOTICE

These attachments are served by Savane. You can download the corresponding
source code of Savane at
https://savannah.gnu.org/source/savane-93e94c53b21509aa1b97bb1fa64bc1f99e22b413.tar.gz

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?67424>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
signature.asc (application/pgp-signature, 228 B)
-----BEGIN PGP SIGNATURE-----

iHUEABYIAB0WIQQk97aszIMMAvLLwm6qLAuaBUf3TgUCaJykPwAKCRCqLAuaBUf3
Tl8RAQC34q+DJELFgq0SU8bk5nDp9rd1ezbf701YxaauMhPwggEApJpq+77E7PXx
H6VjsudrGZpcdC1A39QNrZ7SRBxhrgw=
=IO8G
-----END PGP SIGNATURE-----