Date: Wed, 08 Jan 2020 18:30:57 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 243195] [libc] setlocale(LC_COLLATE, "...") causes segmentation fault after certain number of calls Message-ID: <bug-243195-227@https.bugs.freebsd.org/bugzilla/>
next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D243195 Bug ID: 243195 Summary: [libc] setlocale(LC_COLLATE, "...") causes segmentation fault after certain number of calls Product: Base System Version: 12.1-RELEASE Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: bin Assignee: bugs@FreeBSD.org Reporter: myoga.murase@gmail.com I'm running FreeBSD 12.1-RELEASE in VirtualBox on Windows 10. $ uname -a FreeBSD vm-freebsd 12.1-RELEASE FreeBSD 12.1-RELEASE r354233 GENERIC i386 The following reduced program results in a segmentation fault. $ cat test1.c #include <locale.h> #include <stdio.h> int main(int argc, char** argv) { int i; if (argc !=3D 2) return 2; printf("start\n"); fflush(stdout); for (i =3D 0; i < 100000; i++) { setlocale(LC_COLLATE, argv[1]); setlocale(LC_COLLATE, "C"); } printf("done\n"); fflush(stdout); return 0; } $ gcc -o test1 test1.c $ ./test1 en_US.UTF-8 start Segmentation fault $ ./test1 ja_JP.UTF-8 start Segmentation fault $ ./test1 ja_JP.eucJP start Segmentation fault The number of successful invocation of `setlocale' until the segmentation fault is always the same for the same locale, but it is different for different locales. The segmentation fault is only caused when the category LC_COLLATE is changed (through LC_COLLTE or LC_ALL). There are no problems with the other categories. I suspect the implementation of `__collate_load_tables_l' in `lib/libc/locale/collate.c'. I'm not sure but maybe there is a memory leak caused by missing `munmap'? https://github.com/freebsd/freebsd/blob/b6fca3ee8065a5cfd3a36abfd7a2663eb5b= fee7d/lib/libc/locale/collate.c#L184 --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-243195-227>