Double free or corruption in delscreen()

vcoxvco <[email protected]> Mon, 3 Aug 2026 19:17:34 +0200
Newsgroups gmane.comp.lib.ncurses.bugs
Message-ID <[email protected]>
Hi,

there is a crash in test/test_delwin.c when leaving via ESC using a reentrant ncurses lib.
(when not using --enable-reentrant, there is no crash):


(ncurses-6.6-20260801, gcc 16.1.1, Tumbleweed):
	./configure --enable-reentrant
	make
	cd test
	./test_delwin
	Hit ESC

Result:
	./test_delwin
	double free or corruption (!prev)
	Aborted                    (core dumped) ./test_delwin


gdb says:

#0  0x00007fda16a9fef4 in __pthread_kill_implementation () from /lib64/libc.so.6
#1  0x00007fda16a43046 in raise () from /lib64/libc.so.6
#2  0x00007fda16a2952d in abort () from /lib64/libc.so.6
#3  0x00007fda16a2a571 in __libc_message_impl.cold () from /lib64/libc.so.6
#4  0x00007fda16aab37e in malloc_printerr () from /lib64/libc.so.6
#5  0x00007fda16aace2c in _int_free_merge_chunk () from /lib64/libc.so.6
#6  0x00007fda16aacea5 in _int_free_chunk () from /lib64/libc.so.6
#7  0x00000000004101eb in delscreen (sp=0xf9c2010) at ../ncurses/./base/lib_set_term.c:250
#8  0x00000000004026c4 in next_step (win=0xfa65b50) at ../test/test_delwin.c:51
#9  0x000000000040297e in main (argc=1, argv=0x7fff24e5fef8) at ../test/test_delwin.c:106

It crashes in ../ncurses/./base/lib_set_term.c:250

I tracked that down to ncurses-6.6-20260704, ncurses/base/lib_set_term.c:214:
	#if USE_WIDEC_SUPPORT
		FreeIfNeeded(sp->_wacs_map);
	#endif

When removing this, everything works fine.
(I guess this is not the correct fix ;-) )

And BTW:
When configuring this way:
	./configure --with-debug --disable-stripping --enable-reentrant
I don't get debug symbols.

I have to explicitly set CFLAGS, e.g.
	CFLAGS="-g" ./configure --with-debug --disable-stripping --enable-reentrant
Is this intended, a bug or did I miss something here?

Best regards
Vassili

-- 
V. Courzakis
email: [email protected]