Re: Double free or corruption in delscreen()

Thomas Dickey <[email protected]> Mon, 3 Aug 2026 15:35:07 -0400
Newsgroups gmane.comp.lib.ncurses.bugs
Message-ID <[email protected]>
--WGagUGBBH/mVLhlc
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Mon, Aug 03, 2026 at 07:17:34PM +0200, vcoxvco wrote:
> Hi,
>=20
> there is a crash in test/test_delwin.c when leaving via ESC using a reent=
rant ncurses lib.
> (when not using --enable-reentrant, there is no crash):
>=20
>=20
> (ncurses-6.6-20260801, gcc 16.1.1, Tumbleweed):
> 	./configure --enable-reentrant
> 	make
> 	cd test
> 	./test_delwin
> 	Hit ESC
>=20
> Result:
> 	./test_delwin
> 	double free or corruption (!prev)
> 	Aborted                    (core dumped) ./test_delwin

thanks (in that area, I usually test --with-pthread, which doesn't appear
to run into this bug)
=20
> gdb says:
>=20
> #0  0x00007fda16a9fef4 in __pthread_kill_implementation () from /lib64/li=
bc.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=
=2E6
> #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=3D0xf9c2010) at ../ncurses/./base=
/lib_set_term.c:250
> #8  0x00000000004026c4 in next_step (win=3D0xfa65b50) at ../test/test_del=
win.c:51
> #9  0x000000000040297e in main (argc=3D1, argv=3D0x7fff24e5fef8) at ../te=
st/test_delwin.c:106
>=20
> It crashes in ../ncurses/./base/lib_set_term.c:250
>=20
> 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
>=20
> When removing this, everything works fine.
> (I guess this is not the correct fix ;-) )

right - I'll check/see
=20
> And BTW:
> When configuring this way:
> 	./configure --with-debug --disable-stripping --enable-reentrant
> I don't get debug symbols.
>=20
> I have to explicitly set CFLAGS, e.g.
> 	CFLAGS=3D"-g" ./configure --with-debug --disable-stripping --enable-reen=
trant
> Is this intended, a bug or did I miss something here?

it should work...

--=20
Thomas E. Dickey <[email protected]>
https://invisible-island.net

--WGagUGBBH/mVLhlc
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQGzBAABCgAdFiEEGYgtkt2kxADCLA1WzCr0RyFnvgMFAmpw7WcACgkQzCr0RyFn
vgPvLgv/bfklzFH7Ar6L05oZfblcCwYIXlFKvGXdBb9IFoCIFHcI2u+i7MAGvx/H
s35jVIX9fdJFZ+Lv+8T/5TQvxOdkUKma41ryfQiWsits1lt1OxGp+pJ+zTjzkUdv
lzULUNSi7+WRvGPMR/H4VYnEdjIbuOTweBV4N5U9J055xwH3uhjcdaJOxfygfSJH
FH4QSCSBbzqAmX2OvBECAmHZ3qjIsQNzJCcCqq5R1D/HuQz8np0L6oc6UNAoKdNl
7yLtzJyG0+K/HNO62cwW3BA+U4EiqYAW7FP4/bYVdv+XYFemQidzh+46YXzcKHuo
hxrZvi7cP0Gt2WoZhC4mHmiy4MdRQJmL/0ouzL4NurPrwJo0SSVExpGagiFV1gLA
Jscp7/wCUbxdYZXoTTrKR9D8P4ikhb1pn+bqabBYBkL3iQlcYy7SYble81dHoMI4
WEDVeVvcu8Z6ljHinSn/8ot10oemDE0HZvm6ceo2DmZ9t0pfEUtmdbsxrJZOirXe
QcJer5ug
=WnTj
-----END PGP SIGNATURE-----

--WGagUGBBH/mVLhlc--