Why does musl printf() use so much more stack when printfing floating point numbers?
Create a small test program and run it with different configurations.
Run the test program on Ubuntu with glibc
$ gcc -O0 -o svnprintf svnprintf.c && ./svnprintf
- main() starting
- found paint smudge 1008 bytes into stack
- foo
- found paint smudge 168 bytes into stack
- foo sp=0x7ffd37682110
- found paint smudge 1800 bytes into stack
- foo sp=0x7ffd37682110 sp=0x7ffd37682110
- found paint smudge 1800 bytes into stack
- foo5(): !!1 <= !!2 (=0x7ffd37682126) <= !!3; 1.00% 2
- found paint smudge 2240 bytes into stack
- foo6(): 1.000000
- found paint smudge 2208 bytes into stack
- main() ending
Run the test program on Ubuntu with mpaland printf
$ gcc -DMPALAND -O0 -o svnprintf svnprintf.c && ./svnprintf
- main() starting
- found paint smudge 1008 bytes into stack
- foo
- found paint smudge 648 bytes into stack
- foo sp=00007FFC1C7B7680
- found paint smudge 912 bytes into stack
- foo sp=00007FFC1C7B7680 sp=00007FFC1C7B7680
- found paint smudge 912 bytes into stack
- foo5(): !!1 <= !!2 (=00007FFC1C7B7696) <= !!3; 1.00% 2
- found paint smudge 976 bytes into stack
- foo6(): 1.000000
- found paint smudge 800 bytes into stack
- main() ending
Run test test program on Alpine Linux with musl
$ gcc -O0 -o svnprintf svnprintf.c && ./svnprintf
- main() starting
- found paint smudge 1008 bytes into stack
- foo
- found paint smudge 168 bytes into stack
- foo sp=0x7ffd47ba8e40
- found paint smudge 976 bytes into stack
- foo sp=0x7ffd47ba8e40 sp=0x7ffd47ba8e40
- found paint smudge 976 bytes into stack
- foo5(): !!1 <= !!2 (=0x7ffd47ba8e56) <= !!3; 1.00% 2
- found paint smudge 8792 bytes into stack
- foo6(): 1.000000
- found paint smudge 8728 bytes into stack
- main() ending
Run test test program on Alpine Linux with mpaland printf
$ gcc -DMPALAND -O0 -o svnprintf svnprintf.c && ./svnprintf
- main() starting
- found paint smudge 1008 bytes into stack
- foo
- found paint smudge 592 bytes into stack
- foo sp=00007FFCB19D4E90
- found paint smudge 840 bytes into stack
- foo sp=00007FFCB19D4E90 sp=00007FFCB19D4E90
- found paint smudge 840 bytes into stack
- foo5(): !!1 <= !!2 (=00007FFCB19D4EA6) <= !!3; 1.00% 2
- found paint smudge 904 bytes into stack
- foo6(): 1.000000
- found paint smudge 728 bytes into stack
- main() ending
Stack usage printf()ing one float:
| OS | printf | size |
| ------ | ------- | ----- |
| Ubuntu | glibc | 2,208 |
| Ubuntu | mpaland | 800 |
| Alpine | musl | 8,728 |
| Alpine | mpaland | 728 |
Why does musl-libc use so much more stack space than the other printf() implementations tested?