LC_CTYPE=UTF causes libreadline applications to crash due to invalid locale on non-Ubuntu systems #840

Open
opened 2024-04-18 18:37:58 +02:00 by NCommander · 0 comments
NCommander commented 2024-04-18 18:37:58 +02:00 (Migrated from github.com)

cool-retro-term, at least on macOS, sets LC_FTYPE to UTF-8, and no other locale information. This is an invalid locale (it should be unset, or set to 'C'), but it has a rather disastrous interaction with programs compiled against older versions of readline that have NLS enabled

LANGUAGE=''
LC_CTYPE=UTF-8

This causes bash on illumos to crash when logging via SSH (https://github.com/omniosorg/omnios-build/issues/3537#event-12361550471), which took an extended effort to debug and find. The issue is in most versions of libreadline, but has been patched upstream at this point.

Ubuntu has a special script, /etc/profile.d/01-locale-fix.sh which resets the locale to something valid which prevents this issue from cropping up there.

The problem in cool-retro-term is here: 63228027e1/src/ksession.cpp (L84)

On Linux, it should probably just accept whatever LC_* it gets from the login environment as is. That said, setting LC_CTYPE only affects the output of tolower() , toupper() and isalpha(), and a few other functions, and its usually errorous to set it without other locale information.

cool-retro-term, at least on macOS, sets LC_FTYPE to UTF-8, and no other locale information. This is an invalid locale (it should be unset, or set to 'C'), but it has a rather disastrous interaction with programs compiled against older versions of readline that have NLS enabled ``` LANGUAGE='' LC_CTYPE=UTF-8 ``` This causes bash on illumos to crash when logging via SSH (https://github.com/omniosorg/omnios-build/issues/3537#event-12361550471), which took an extended effort to debug and find. The issue is in most versions of libreadline, but has been patched upstream at this point. Ubuntu has a special script, `/etc/profile.d/01-locale-fix.sh` which resets the locale to something valid which prevents this issue from cropping up there. The problem in cool-retro-term is here: https://github.com/Swordfish90/qmltermwidget/blob/63228027e1f97c24abb907550b22ee91836929c5/src/ksession.cpp#L84 On Linux, it should probably just accept whatever LC_* it gets from the login environment as is. That said, setting LC_CTYPE only affects the output of tolower() , toupper() and isalpha(), and a few other functions, and its usually errorous to set it without other locale information.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: seeseemelk/cool-retro-term#840
No description provided.