Project

General

Profile

Actions

Bug #1047

closed

ksh overwrites child core files

Added by Gordon Ross about 12 years ago. Updated over 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Start date:
2011-05-18
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
needs-triage
Gerrit CR:
External Bug:

Description

This script:

#!/bin/sh
find . -name '*.[ch]' -print | sort

Run with these environment settings:
LANG=en_US.UTF-8
LC_COLLATE=C

and run in this illumos directory:
$ cd $SRC/cmd/smbsrv

$ ~/bin/findch
Memory fault(coredump)
$ file core
core: ELF 32-bit LSB core file 80386 Version 1, from 'findch'
$ mdb core
08047858 libc_hwcap1.so.1`kill+0x15(fee07bb0, 0, a, fedb01c5)
08047938 libshell.so.1`sh_main+0x840(2, 8047998, 0, fee6e9f2, 4, 0)
08047968 main+0x4a(2, 8047998, 80479a4, 804798c)
0804798c _start+0x7d(2, 8047ab8, 8047ac0, 0, 8061210, 8047af9)

After using coreadm as follows:
coreadm -i core.%p
one can observe that the real reason for this core was
the child (sort) having dumped core, after which ksh
does a kill(2) of itself with the signal from the child.
[alanc reports this is 7008357]

The reason for the child core was
https://www.illumos.org/issues/1046

ksh should avoid making itself dump core here.


Related issues

Related to illumos gate - Feature #13405: ksh93 update to 2012-08-01ClosedAndy Fiddaman

Actions
Actions #1

Updated by Gordon Ross about 12 years ago

  • Subject changed from ksh script (find|sort) core dump to ksh overwrites child core files

This appears to be in libshell : fault.c 630

    if(savxit&SH_EXITSIG)
        sig = savxit&SH_EXITMASK;
    if(sig)
    {
        /* generate fault termination code */
        signal(sig,SIG_DFL);
        sigrelease(sig);
        kill(getpid(),sig);
        pause();
    }

Actions #2

Updated by Gordon Ross about 12 years ago

ksh93 appears to have fixed this by doing an "rlimit core 0"
before sending itself the fatal signal from the child status.

--- a/usr/src/lib/libshell/common/sh/fault.c    Tue Apr 13 14:24:21 2010
+++ b/usr/src/lib/libshell/common/sh/fault.c    Wed Mar  9 22:04:01 2011
@@ -632,6 +645,17 @@
     if(sig)
     {
         /* generate fault termination code */
+        if(RLIMIT_CORE!=RLIMIT_UNKNOWN)
+        {
+#ifdef _lib_getrlimit
+            struct rlimit rlp;
+            getrlimit(RLIMIT_CORE,&rlp);
+            rlp.rlim_cur = 0;
+            setrlimit(RLIMIT_CORE,&rlp);
+#else
+            vlimit(RLIMIT_CORE,0);
+#endif
+        }
         signal(sig,SIG_DFL);
         sigrelease(sig);
         kill(getpid(),sig);

Actions #3

Updated by Andy Fiddaman over 2 years ago

Actions #4

Updated by Electric Monk over 2 years ago

  • Gerrit CR set to 1175
Actions #5

Updated by Electric Monk over 2 years ago

  • Status changed from New to Closed
  • % Done changed from 0 to 100

git commit b30d193948be5a7794d7ae3ba0ed9c2f72c88e0f

commit  b30d193948be5a7794d7ae3ba0ed9c2f72c88e0f
Author: Andy Fiddaman <omnios@citrus-it.co.uk>
Date:   2021-01-30T17:13:33.000Z

    13405 ksh93 update to 2012-08-01
    13434 sh: mishandles backslash as last character of a block of input
    11750 ksh mkdir builtin doesn't honor special file permissions
    9199 ksh93 builtin *grep -v mishandles blank lines, blows up libgcrypt-config
    6756 sh (and ksh) have issues with ${1+"$@"}
    6520 ksh: sleep could wait forever
    4860 ksh93: core in printf
    3791 /bin/sh's builtin 'rm' busted: 'rm -f' without arguments returns error
    1047 ksh overwrites child core files
    880 ksh93 coredumps on 'unset'
    499 "interrupted system call" when using "tee" builtin in ksh
    Reviewed by: Robert Mustacchi <rm@fingolfin.org>
    Reviewed by: Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
    Reviewed by: Dominik Hassler <hadfl@omnios.org>
    Approved by: Rich Lowe <richlowe@richlowe.net>

Actions

Also available in: Atom PDF