Bug 20249 - vfprintf uses too much stack space
Summary: vfprintf uses too much stack space
Status: NEW
Alias: None
Product: glibc
Classification: Unclassified
Component: stdio (show other bugs)
Version: 2.24
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-06-13 10:14 UTC by Florian Weimer
Modified: 2016-06-13 10:14 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Florian Weimer 2016-06-13 10:14:36 UTC
Bug 20248 notes vfprintf uses too much stack space:

printf calls vfprintf (~1760 bytes of stack space), vfprintf calls buffered_vfprintf (~8592 bytes of stack space), and this calls vfprintf again (~1760 bytes of stack space).  Total space requirement is around 12 KiB.

We should rearrange things so that the second vfprintf stack frame is not needed, and reduce the buffer size in buffered_vfprintf.

I think it is reasonable to assume that you can call fprintf on an unbuffered stream while having a buffer of BUFSIZ on the stack, from a thread which has a PTHREAD_STACK_MIN stack allocation.  On some architectures, the numbers currently do not allwo this.