patch 9.2.0650: Vim aborts at startup when built with the example -O2 CFLAGS
Commit: https://github.com/vim/vim/commit/dd4fbdb392e72097a67da20838216d9b9600363b Author: Hirohito Higashi <[email protected]> Date: Mon Jun 15 18:20:15 2026 +0000 patch 9.2.0650: Vim aborts at startup when built with the example -O2 CFLAGS Problem: Building with an optimizing example CFLAGS line in src/Makefile (which bypasses configure) aborts Vim at startup with a buffer overflow, because the compiler then defaults _FORTIFY_SOURCE to a level >= 2 (user202729) Solution: Define FORTIFY_CFLAGS with -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 and reference it from the optimizing example CFLAGS lines, the same pin configure already applies; at higher levels the check false-positives on the "x[1] but actually longer" struct-hack arrays. fixes: #20526 closes: #20530 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Signed-off-by: Hirohito Higashi <[email protected]> Signed-off-by: Christian Brabandt <[email protected]> diff --git a/src/Makefile b/src/Makefile index 1a6fa1c66..f66d94f1a 100644 --- a/src/Makefile +++ b/src/Makefile @@ -597,13 +597,19 @@ CClink = $(CC) #CFLAGS = -O -Olimit 2000 #CFLAGS = -O -FOlimit,2000 +# Add $(FORTIFY_CFLAGS) to optimizing example lines below: at higher levels +# (the compiler default with -O) the buffer overflow check aborts Vim on the +# "x[1] but actually longer" struct-hack arrays (e.g. dictitem di_key). +# configure adds this automatically; these examples bypass it. +FORTIFY_CFLAGS = -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 + # Often used for GCC: mixed optimizing, lot of optimizing, debugging -#CFLAGS = -g -O2 -fno-strength-reduce -Wall -Wshadow -Wmissing-prototypes -#CFLAGS = -g -O2 -fno-strength-reduce -Wall -Wmissing-prototypes +#CFLAGS = -g -O2 -fno-strength-reduce -Wall -Wshadow -Wmissing-prototypes $(FORTIFY_CFLAGS) +#CFLAGS = -g -O2 -fno-strength-reduce -Wall -Wmissing-prototypes $(FORTIFY_CFLAGS) #CFLAGS = -g -Wall -Wmissing-prototypes -#CFLAGS = -O6 -fno-strength-reduce -Wall -Wshadow -Wmissing-prototypes +#CFLAGS = -O6 -fno-strength-reduce -Wall -Wshadow -Wmissing-prototypes $(FORTIFY_CFLAGS) #CFLAGS = -g -DDEBUG -Wall -Wshadow -Wmissing-prototypes -#CFLAGS = -g -O2 '-DSTARTUPTIME="vimstartup"' -fno-strength-reduce -Wall -Wmissing-prototypes +#CFLAGS = -g -O2 '-DSTARTUPTIME="vimstartup"' -fno-strength-reduce -Wall -Wmissing-prototypes $(FORTIFY_CFLAGS) # Use this with GCC to check for mistakes, unused arguments, etc. # Note: If you use -Wextra and get warnings in GTK code about function diff --git a/src/version.c b/src/version.c index 392bae84c..ff26c4350 100644 --- a/src/version.c +++ b/src/version.c @@ -759,6 +759,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 650, /**/ 649, /**/ -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/vim_dev/E1wZCIy-00GpoX-VK%40256bit.org.
