Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ksh93 dumps core in emacs mode while entering characters in different locale. #6

Closed
lijog opened this issue Mar 14, 2016 · 2 comments
Closed

Comments

@lijog
Copy link

lijog commented Mar 14, 2016

I observed this issue in a Solaris 11 system on ksh2012-08-01, ie the master version. I guess this issue is present in the later versions too as the relevant code has not changed.

The issue can be reproduced if we add Asian locales to ibus (such as Korean).
In the ksh93 shell prompt, input some Asian character. ksh promptly dumps core with the following stacktrace.

bash-4.2$ pstack core
core 'core' of 1134: ksh
00000000004f1cf4 ed_emacsread () + 404
00000000004a5096 slowread () + 116
0000000000592d12 sfrd () + 482
000000000058b707 _sffilbuf () + 297
00000000005936ac sfreserve () + 2ac
0000000000477ae2 exfile () + 6e2
0000000000477393 sh_main () + af3
00000000004767dd main () + 4d
0000000000476614 ???????? ()

The coredump happens at the following line no 320 in src/cmd/ksh93/edit/emacs.c
i.e if(c!='\t' && c!=ESC && !isdigit(c)).

I referred the vi.c code and added the digit(c) macro, i.e
((c&~STRIP)==0 && isdigit(c)) and replaced the isdigit(c) usage with the "digit(c)" macro. Here's the patch which fixes the issue for me.

--- INIT.2012-08-01.old/src/cmd/ksh93/edit/emacs.c 2016-01-18 03:52:58.380801240 -0800
+++ INIT.2012-08-01/src/cmd/ksh93/edit/emacs.c 2016-02-05 01:39:08.350312914 -0800
@@ -90,6 +90,7 @@
static int print(int);
static int _isword(int);

define isword(c) _isword(out[c])

+# define digit(c) ((c&~STRIP)==0 && isdigit(c))

#else

define gencpy(a,b) strcpy((char_)(a),(char_)(b))

@@ -97,6 +98,7 @@

define genlen(str) strlen(str)

define print(c) isprint(c)

define isword(c) (isalnum(out[c]) || (out[c]=='_'))

+# define digit(c) isdigit(c)
#endif /*SHOPT_MULTIBYTE */

typedef struct emacs
@@ -317,7 +319,7 @@
count = 1;
adjust = -1;
i = cur;

  •           if(c!='\t' && c!=ESC && !isdigit(c))
    
  •           if(c!='\t' && c!=ESC && !digit(c))
                    ep->ed->e_tabcount = 0;
            switch(c)
            {
    
    @@ -775,7 +777,7 @@
    int digit,ch;
    digit = 0;
    value = 0;
  •   while ((i=ed_getchar(ep->ed,0)),isdigit(i))
    
  •   while ((i=ed_getchar(ep->ed,0)),digit(i))
    {
            value *= 10;
            value += (i - '0');
    
    @@ -1013,7 +1015,7 @@
    {
    i=ed_getchar(ep->ed,0);
    ed_ungetchar(ep->ed,i);
  •                                   if(isdigit(i))
    
  •                                   if(digit(i))
                                            ed_ungetchar(ep->ed,ESC);
                            }
                    }
    
@siteshwar
Copy link
Contributor

@lijog Are you able to reproduce it if you build from current master branch ?

@siteshwar
Copy link
Contributor

I am closing this bug due to lack of activity. Please reopen if it is still reproducible.

McDutchie added a commit to ksh93/ksh that referenced this issue Jan 8, 2021
This change is pulled from here:
https://github.com/oracle/solaris-userland/blob/master/components/ksh93/patches/240-22461939.patch

Information:
att#6

George Lijo wrote on 14 Mar 2016:
> I observed this issue in a Solaris 11 system on ksh2012-08-01
> [...]. The issue can be reproduced if we add Asian locales to
> ibus (such as Korean). In the ksh93 shell prompt, input some
> Asian character. ksh promptly dumps core [...].
>
> The coredump happens at the following line no 320 in
> src/cmd/ksh93/edit/emacs.c
>	if(c!='\t' && c!=ESC && !isdigit(c)).
>
> I referred the vi.c code and added the digit(c) macro, i.e.
> ((c&~STRIP)==0 && isdigit(c)) and replaced the isdigit(c) usage
> with the "digit(c)" macro.
gkamat pushed a commit to gkamat/ast that referenced this issue Apr 28, 2021
Backport the ksh2020 fix for timezone name determination

Partial fix for att#6.
gkamat pushed a commit to gkamat/ast that referenced this issue Apr 28, 2021
"UTC" is the modern name for what used to be "GMT", but ksh still
preferred GMT. On systems configured to use the UTC time zone, this
caused a 'printf %T' regression test failure in tests/builtins.sh
as the external 'data' utility will prefer UTC these days.

src/lib/libast/tm/tmdata.c:
- Reorder the name alternatives for UTC/GMT so that UTC is
  the first preference.

src/cmd/ksh93/tests/builtins.sh:
- Report expected and actual values on 'printf %T' failure.

Related: att#6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants