Bug 265319

Summary: localedef -c explodes with internal fault (/usr/src/usr.bin/localedef/localedef.c:89)
Product: Base System Reporter: наб <nabijaczleweli>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: New ---    
Severity: Affects Only Me CC: bapt, markj, nabijaczleweli, yuripv
Priority: ---    
Version: CURRENT   
Hardware: Any   
OS: Any   

Description наб 2022-07-19 23:33:49 UTC
[build@build /tmp]$ uname -a
FreeBSD build 13.1-RELEASE FreeBSD 13.1-RELEASE releng/13.1-n250148-fc952ac2212 GENERIC amd64

[build@build /tmp]$ localedef  -cv ./"cs_CZ.UTF-8"
Processing locale ./cs_CZ.UTF-8.
Loading POSIX portable characters.
internal fault (/usr/src/usr.bin/localedef/localedef.c:89)^C

This appears to correspond to the INTERR in
const char *
category_name(void)
{
	switch (get_category()) {
	case T_CHARMAP:
		return ("CHARMAP");
	case T_WIDTH:
		return ("WIDTH");
	case T_COLLATE:
		return ("LC_COLLATE");
	case T_CTYPE:
		return ("LC_CTYPE");
	case T_MESSAGES:
		return ("LC_MESSAGES");
	case T_MONETARY:
		return ("LC_MONETARY");
	case T_NUMERIC:
		return ("LC_NUMERIC");
	case T_TIME:
		return ("LC_TIME");
	default:
		INTERR;
		return (NULL);
	}
}
Comment 1 Yuri Pankov freebsd_committer freebsd_triage 2023-03-29 10:53:05 UTC
That likely depends on the data you are providing to localedef, could you provide it here?

Also, what is the expected outcome of this problem report? The parsing problem seems to be handled gracefully, not causing a crash.
Comment 2 наб 2023-03-29 11:34:59 UTC
If it did, I'd've included it. This happens before it reads the first byte:

$ localedef  -cv ./"cs_CZ.UTF-8" < /dev/null
Processing locale ./cs_CZ.UTF-8.
Loading POSIX portable characters.
internal fault (/usr/src/usr.bin/localedef/localedef.c:89)<stdin>: 1: error: syntax error
$ sleep 1000 | localedef  -cv ./"cs_CZ.UTF-8"
Processing locale ./cs_CZ.UTF-8.
Loading POSIX portable characters.
internal fault (/usr/src/usr.bin/localedef/localedef.c:89)

Re-tested on FreeBSD build 13.1-RELEASE-p6 FreeBSD 13.1-RELEASE-p6 GENERIC amd64.
Comment 3 Yuri Pankov freebsd_committer freebsd_triage 2023-03-29 11:39:49 UTC
(In reply to наб from comment #2)
localedef works just fine for locale data built during buildworld.  What I am asking is what change do you expect from this problem report as I don't see any real problem reported?  Please correct me if I'm wrong.