Hi! ----
Glenn, can you take a look at the old email/issue below, please ? I'm still seeing issues with ast-ksh.2013-02-22 on SuSE 12.2/AMD64/64bit build when it executes an interactive ksh93 shell under valgrind control using the "none" valgrind utility (which - in theory - should exactly behave as valgrind isn't involved). Example: -- snip -- $ valgrind --tool=none ./arch/linux.i386-64/bin/ksh ==13618== Nulgrind, the minimal Valgrind tool ==13618== Copyright (C) 2002-2011, and GNU GPL'd, by Nicholas Nethercote. ==13618== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info ==13618== Command: ./arch/linux.i386-64/bin/ksh ==13618== h:w> -- snip -- ... the expected ksh93 prompt on SuSE 12.2 would look (in my case) "test001@suse122vm001:/home/test001/work/ast_ksh_20130222/build_i386_64bit_debug" ... but instead I get "h:w> " ... ... my guess is that something is wrong with |vfork()| vs. valgrinds replacement of |vfork()| with |fork()| as described below... ---------- Forwarded message ---------- From: John Reiser <[email protected]> Date: Tue, Jul 3, 2012 at 5:19 PM Subject: Re: [Valgrind-developers] Shell fails when under valgrind-3.7.0's control with "--tool=none" ? To: [email protected] Cc: [email protected] On 07/02/2012, John Reiser wrote: > I find hints that it's an application bug [ksh bug] involving vfork(). Confirmed: there _is_ something about ksh use of vfork. This puts the onus on ksh, although valgrind might not be entirely blameless. The kernel sends SIGCHLD after ENOEXEC+exit_group from the child of vfork(). Valgrind forces the vfork() to be a full fork(), pre-fails the execve due to "not executable by kernel", and it's difficult to see what happens to the SIGCHLD (if any.) The context begins with output from "valgrind --trace-syscalls=yes ...": > SYSCALL[11486,1]( 3) sys_close ( 4 )[sync] --> Success(0x0:0x0) > SYSCALL[11486,1]( 8) sys_lseek ( 10, 1192, 0 )[sync] --> Success(0x0:0x4a8) > SYSCALL[11486,1]( 14) sys_rt_sigprocmask ( 0, 0x7feffb8c0, 0x7729c0, 8 ) --> > [pre-success] Success(0x0:0x0) > > SYSCALL[11486,1]( 58) sys_fork ( ) fork: process 11486 created child 11489 > --> [pre-success] Success(0x0:0x2ce1) ### Note that valgrind has coerced vfork() into full fork(). > > SYSCALL[11486,1]( 14) sys_rt_sigprocmask ( 2, 0x7729c0, 0x0, 8 ) --> > [pre-success] Success(0x0:0x0) > --> [pre-success] Success(0x0:0x0) > SYSCALL[11489,1]( 14) sys_rt_sigprocmask ( 2, 0x7729c0, 0x0, 8 ) --> > [pre-success] Success(0x0:0x0) > SYSCALL[11489,1]( 59) sys_execve ( 0x4a31439(./myscript), 0x4a310f0, > 0x4a31248 ) --> [pre-fail] Failure(0x8) ### Note that "Failure(0x8)" is ENOEXEC. > SYSCALL[11489,1](231) exit_group( 126 ) --> [pre-success] Success(0x0:0x0) > ==11489== > SYSCALL[11486,1]( 3) sys_close ( 1 )[sync] --> Success(0x0:0x0) > SYSCALL[11486,1]( 72) sys_fcntl[ARG3=='arg'] ( 12, 0, 1 )[sync] --> > Success(0x0:0x1) > SYSCALL[11486,1]( 3) sys_close ( 12 )[sync] --> Success(0x0:0x0) > SYSCALL[11486,1]( 0) sys_read ( 3, 0x7feffbb60, 8192 ) --> [async] ... Note that ./myscript is not executable by the kernel itself. It has +x file permission, but is not ELF and has no "#!" interpreter marking. $ ls -l ./arch/linux.i386-64/bin/myscript -rwxrwxr-x. 1 jreiser jreiser 868 Jul 2 10:39 ./arch/linux.i386-64/bin/myscript $ sed 3q <./arch/linux.i386-64/bin/myscript tests=$* typeset -A blop function blop.get $ Thus if ./myscript is to be executed, then ksh must recover from the failed kernel execve, and ksh itself must execute ./myscript "by hand". If run under strace instead of valgrind, then the same portion of execution is: ----- close(4) = 0 lseek(10, 1192, SEEK_SET) = 1192 rt_sigprocmask(SIG_BLOCK, [HUP INT QUIT PIPE CHLD], [], 8) = 0 vfork(Process 1589 attached <unfinished ...> ### Note the use of vfork just above, while valgrind has coerced vfork ==> fork. [pid 1589] rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0 [pid 1589] execve("./myscript", ["./myscript", "1"], [/* 54 vars */]) = -1 ENOEXEC (Exec format error) ### The ENOEXEC is the same as valgrind's "Failure(0x8)". [pid 1589] exit_group(126) = ? [pid 1586] <... vfork resumed> ) = 1589 [pid 1589] +++ exited with 126 +++ wait4(1589, NULL, 0, NULL) = 1589 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0 --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=1589, si_status=126, si_utime=0, si_stime=0} --- ### Here begins the divergence. strace reports exit_group(126) and SIGCHLD. valgrind reports exit_group(126) but perhaps no SIGCHLD. valgrind does not announce any SIGCHLD (which is signal 17), but valgrind does report > SYSCALL[11486,1]( 15) sys_rt_sigreturn ( ) --> [pre-success] NoWriteResult and > SYSCALL[11486,1]( 13) sys_rt_sigaction ( 17, 0x7feffb830, 0x7feffb8d0, 8 ) --> [pre-success] Success(0x0:0x0) (see below.) rt_sigreturn() = 0 open("./myscript", O_RDONLY) = 4 stat("/dev/fd/4", {st_mode=S_IFREG|0775, st_size=868, ...}) = 0 rt_sigprocmask(SIG_BLOCK, [HUP INT QUIT PIPE CHLD], [], 8) = 0 vfork(Process 1590 attached <unfinished ...> [pid 1590] rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0 [pid 1590] execve("</absolute/path/to>/arch/linux.i386-64/bin/ksh", ["./myscript", "/dev/fd/4", "1"], [/* 54 vars */] <unfinished ...> [pid 1586] <... vfork resumed> ) = 1590 [pid 1586] rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0 [pid 1586] close(4) = 0 [pid 1590] <... execve resumed> ) = 0 [pid 1586] close(1 <unfinished ...> [pid 1590] brk(0 <unfinished ...> [pid 1586] <... close resumed> ) = 0 [pid 1590] <... brk resumed> ) = 0x2061000 [pid 1586] fcntl(12, F_DUPFD, 1 <unfinished ...> [pid 1590] mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0 <unfinished ...> ----- > SYSCALL[11489,1](231) exit_group( 126 ) --> [pre-success] Success(0x0:0x0) > ==11489== > SYSCALL[11486,1]( 3) sys_close ( 1 )[sync] --> Success(0x0:0x0) > SYSCALL[11486,1]( 72) sys_fcntl[ARG3=='arg'] ( 12, 0, 1 )[sync] --> > Success(0x0:0x1) > SYSCALL[11486,1]( 3) sys_close ( 12 )[sync] --> Success(0x0:0x0) > SYSCALL[11486,1]( 0) sys_read ( 3, 0x7feffbb60, 8192 ) --> [async] ... > SYSCALL[11486,1]( 15) sys_rt_sigreturn ( ) --> [pre-success] NoWriteResult ### At this point under strace, then ksh has begun its exec-of-shell-script-without-#! using: open("./myscript", O_RDONLY) = 4 but under valgrind, then ksh enters a "hard fail" path. > SYSCALL[11486,1]( 61) sys_wait4 ( -1, 0x7feffbb1c, 11, 0x0 ) --> [async] ... > SYSCALL[11486,1]( 61) ... [async] --> Success(0x0:0x2ce1) > SYSCALL[11486,1]( 61) sys_wait4 ( -1, 0x7feffbb1c, 11, 0x0 ) --> [async] ... > SYSCALL[11486,1]( 61) ... [async] --> Failure(0xa) > SYSCALL[11486,1]( 13) sys_rt_sigaction ( 17, 0x7feffb830, 0x7feffb8d0, 8 ) > --> [pre-success] Success(0x0:0x0) > SYSCALL[11486,1]( 0) sys_read ( 3, 0x7feffbb60, 8192 ) --> [async] ... > SYSCALL[11486,1]( 0) ... [async] --> Success(0x0:0x0) > SYSCALL[11486,1]( 3) sys_close ( 3 )[sync] --> Success(0x0:0x0) > SYSCALL[11486,1]( 16) sys_ioctl ( 2, 0x540f, 0x7feffdc70 ) --> [async] ... > SYSCALL[11486,1]( 16) ... [async] --> Success(0x0:0x0) > SYSCALL[11486,1]( 72) sys_fcntl[ARG3=='arg'] ( 1, 0, 3 )[sync] --> > Success(0x0:0x3) > SYSCALL[11486,1]( 3) sys_close ( 1 )[sync] --> Success(0x0:0x0) > SYSCALL[11486,1]( 72) sys_fcntl[ARG3=='arg'] ( 3, 2, 1 )[sync] --> > Success(0x0:0x0) > SYSCALL[11486,1]( 3) sys_close ( 1 )[sync] --> Failure(0x9) > SYSCALL[11486,1]( 72) sys_fcntl[ARG3=='arg'] ( 11, 0, 1 )[sync] --> > Success(0x0:0x1) > SYSCALL[11486,1]( 3) sys_close ( 11 )[sync] --> Success(0x0:0x0) > SYSCALL[11486,1]( 8) sys_lseek ( 3, 0, 1 )[sync] --> Success(0x0:0x0) > SYSCALL[11486,1]( 8) sys_lseek ( 3, 0, 1 )[sync] --> Success(0x0:0x0) > SYSCALL[11486,1]( 0) sys_read ( 3, 0x4a4b050, 65536 ) --> [async] ... > SYSCALL[11486,1]( 0) ... [async] --> Success(0x0:0x0) > SYSCALL[11486,1]( 3) sys_close ( 3 )[sync] --> Success(0x0:0x0) > SYSCALL[11486,1]( 1) sys_write ( 1, 0x4a4b050, 73 ) --> [async] ... > compound var arithmetic failed, expected '( bar=2 baz=3 foo=1 )', got '' > ----- > -- -- __ . . __ (o.\ \/ /.o) [email protected] \__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer /O /==\ O\ TEL +49 641 3992797 (;O/ \/ \O;) _______________________________________________ ast-developers mailing list [email protected] http://lists.research.att.com/mailman/listinfo/ast-developers
