To be noted: the mount system call used in Linux requires five
arguments source, target, filesystemtype, mount flags, and data.
In other words using mount with only four arguments for the
3D file system, which is unkown under Linux, cause an error in
valgrind.  I've done a simple patch to work around this problem.
On the other hand the 3D file system is not known under Linux,
therefore it should safe to use -DSHOPT_FS_3D=0 as compile option.

Beside this I've detected that for -DSHOPT_SPAWN=0 or SHOPT_SPAWN=1
any command cause a clone() together with a vfork() system call.
After adding -DSHOPT_AMP=1 together with SHOPT_SPAWN=1 this is
gone and only clone() is used.

Questions: For what is the macro option SHOPT_AMP intended for?
Does it cause any unwanted side effects if -DSHOPT_AMP=1 is used?

All these changes do not fix the crash ist self but help to run
on other wrong memory alignments.

I've also tried out to use

       #define _mem_sbrk        0
       #define _mem_mmap_anon   0
       #define _mem_mmap_zero   0

in arch/linux.i386-64/src/lib/libast/FEATURE/vmalloc to force
the usage of _std_malloc ... with this valgrind reports in
deeper subshells things like

 ==4645== Invalid read of size 1
 ==4645==    at 0x42F1E4: comsubst (macro.c:1833)
 ==4645==    by 0x42BE48: varsub (macro.c:1015)
 ==4645==    by 0x42A41F: copyto (macro.c:556)
 ==4645==    by 0x428870: sh_mactrim (macro.c:170)
 ==4645==    by 0x430E59: nv_setlist (name.c:193)
 ==4645==    by 0x44ADF9: sh_exec (xec.c:698)
 ==4645==    by 0x44D13F: sh_exec (xec.c:1314)
 ==4645==    by 0x44E159: sh_exec (xec.c:1578)
 ==4645==    by 0x44E3C6: sh_exec (xec.c:1619)
 ==4645==    by 0x44D171: sh_exec (xec.c:1318)
 ==4645==    by 0x44DD2A: sh_exec (xec.c:1513)
 ==4645==    by 0x44D13F: sh_exec (xec.c:1314)
 ==4645==  Address 0x578BE27 is 1 bytes before a block of size 8,193 alloc'd
 ==4645==    at 0x4C21D06: malloc (in 
/usr/lib64/valgrind/amd64-linux/vgpreload_memcheck.so)
 ==4645==    by 0x4195D5: sh_iostream (io.c:443)
 ==4645==    by 0x446438: sh_subtmpfile (subshell.c:141)
 ==4645==    by 0x44C3C6: sh_exec (xec.c:1019)
 ==4645==    by 0x44D1F7: sh_exec (xec.c:1332)
 ==4645==    by 0x44714C: sh_subshell (subshell.c:417)
 ==4645==    by 0x42EEFB: comsubst (macro.c:1764)
 ==4645==    by 0x42BE48: varsub (macro.c:1015)
 ==4645==    by 0x42A41F: copyto (macro.c:556)
 ==4645==    by 0x428870: sh_mactrim (macro.c:170)
 ==4645==    by 0x430E59: nv_setlist (name.c:193)
 ==4645==    by 0x44ADF9: sh_exec (xec.c:698)

...

        Werner

-- 
 Dr. Werner Fink <werner at suse.de>
 SuSE LINUX Products GmbH,  Maxfeldstrasse 5,  Nuernberg,  Germany
 GF: Markus Rex,  HRB 16746 (AG Nuernberg)
 phone: +49-911-740-53-0,  fax: +49-911-3206727,  www.opensuse.org
------------------------------------------------------------------
  "Having a smoking section in a restaurant is like having
          a peeing section in a swimming pool." -- Edward Burr
-------------- next part --------------
--- src/cmd/ksh93/sh/jobs.c
+++ src/cmd/ksh93/sh/jobs.c     2007-09-12 14:25:34.000000000 +0000
@@ -1011,12 +1011,14 @@ void    job_clear(void)
                {
                        pw = pw->p_nxtproc;
                        free((void*)px);
+                       px = (struct process *)0;
                }
        }
        for(jp=bck.list; jp;jp=jpnext)
        {
                jpnext = jp->next;
                free((void*)jp);
+               jp = (struct jobsave *)0;
        }
        bck.list = 0;
        if(njob_savelist < NJOB_SAVELIST)
@@ -1638,7 +1640,10 @@ static int job_chksave(register pid_t pi
                        job_savelist = jp;
                }
                else
+               {
                        free((void*)jp);
+                       jp = (struct jobsave *)0;
+               }
        }
        return(r);
 }
@@ -1673,6 +1678,7 @@ void job_subrestore(void* ptr)
        {
                jpnext = jp->next;
                free((void*)jp);
+               jp = (struct jobsave *)0;
        }
        free(ptr);
        job_unlock();
--- src/cmd/ksh93/sh/init.c
+++ src/cmd/ksh93/sh/init.c     2007-09-12 15:09:14.000000000 +0000
@@ -686,7 +686,7 @@ static const Namdisc_t SH_MATCH_disc  = 
                *newp++ = 0;
                if(lastp=strchr(newp,':'))
                        *lastp = 0;
-               mount((mode?newp:""),oldp,FS3D_VIEW,0);
+               mount((mode?newp:""),oldp,FS3D_FSTYPE(FS3D_VIEW),NiL);
                newp[-1] = ':';
                oldp = newp;
                newp=lastp;
--- src/cmd/ksh93/sh/xec.c
+++ src/cmd/ksh93/sh/xec.c      2007-09-11 14:46:14.000000000 +0000
@@ -755,10 +755,11 @@ int sh_exec(register const Shnode_t *t, 
                                if(np && is_abuiltin(np))
                                {
                                        void *context;
-                                       int scope=0, jmpval, save_prompt,share;
+                                       int scope=0, jmpval, 
save_prompt,share=0;
                                        struct checkpt buff;
                                        unsigned long was_vi=0, was_emacs=0, 
was_gmacs=0;
                                        struct stat statb;
+                                       memset(&statb, 0, sizeof(struct stat));
                                        if(strchr(nv_name(np),'/'))
                                        {
                                                /*
--- src/cmd/ksh93/bltins/cd_pwd.c
+++ src/cmd/ksh93/bltins/cd_pwd.c       2007-09-12 15:10:08.000000000 +0000
@@ -264,10 +264,10 @@ int       b_pwd(int argc, char *argv[],void *e
        if(flag)
        {
 #if SHOPT_FS_3D
-               if(shp->lim.fs3d && (flag = 
mount(e_dot,NIL(char*),FS3D_GET|FS3D_VIEW,0))>=0)
+               if(shp->lim.fs3d && (flag = 
mount(e_dot,NIL(char*),FS3D_FSTYPE(FS3D_GET|FS3D_VIEW),NiL))>=0)
                {
                        cp = (char*)stakseek(++flag+PATH_MAX);
-                       mount(e_dot,cp,FS3D_GET|FS3D_VIEW|FS3D_SIZE(flag),0);
+                       
mount(e_dot,cp,FS3D_FSTYPE(FS3D_GET|FS3D_VIEW|FS3D_SIZE(flag)),NiL);
                }
                else
 #endif /* SHOPT_FS_3D */
--- src/cmd/ksh93/bltins/misc.c
+++ src/cmd/ksh93/bltins/misc.c 2007-09-12 15:10:41.000000000 +0000
@@ -537,10 +537,10 @@ int       b_universe(int argc, char *argv[],vo
            case 0:
            case 1:
                flag |= FS3D_GET;
-               if((n = mount(*argv,(char*)0,flag,0)) >= 0)
+               if((n = mount(*argv,(char*)0,"",flag,NiL)) >= 0)
                {
                        vend = stakalloc(++n);
-                       n = mount(*argv,vend,flag|FS3D_SIZE(n),0);
+                       n = 
mount(*argv,vend,FS3D_FSTYPE(flag|FS3D_SIZE(n)),NiL);
                }
                if(n < 0)
                        goto failed;
@@ -573,7 +573,7 @@ int b_universe(int argc, char *argv[],vo
                        sh_subfork();
                for(n=0;n<argc;n+=2)
                {
-                       if(mount(argv[n+1],argv[n],flag,0)<0)
+                       if(mount(argv[n+1],argv[n],FS3D_FSTYPE(flag),NiL)<0)
                                goto failed;
                }
        }
--- src/lib/libast/comp/conf.sh
+++ src/lib/libast/comp/conf.sh 2007-09-13 10:39:15.000000000 +0000
@@ -143,7 +143,7 @@ main()
        return 1;
 #else
        _ast_intmax_t           s = 0x7fffffffffffffffLL;
-       unsigned _ast_intmax_t  u = 0xffffffffffffffffLL;
+       unsigned _ast_intmax_t  u = 0xffffffffffffffffULL;
 
        return 0;
 #endif
@@ -785,7 +785,11 @@ defined() # list-file
                        cat <<!
 ${head}
 #include <sys/types.h>
+#include <sys/uio.h>
 #include <limits.h>
+#if defined(__linux__)
+#include <linux/limits.h>
+#endif
 #include <unistd.h>$systeminfo$headers
 ${tail}
 #undef conf
@@ -813,7 +817,11 @@ unsigned int conf[] = {
                cat <<!
 ${head}
 #include <sys/types.h>
+#include <sys/uio.h>
 #include <limits.h>
+#if defined(__linux__)
+#include <linux/limits.h>
+#endif
 #include <unistd.h>$systeminfo$headers
 ${tail}
 #undef conf
@@ -854,7 +862,11 @@ done
        cat <<!
 ${head}
 #include <sys/types.h>
+#include <sys/uio.h>
 #include <limits.h>
+#if defined(__linux__)
+#include <linux/limits.h>
+#endif
 #include <unistd.h>$systeminfo$headers
 ${tail}
 #undef conf
@@ -1031,7 +1043,7 @@ do        eval name=\"'$'CONF_name_$key\"
        case $flags in
        *[Ll]*) d=
                case ${conf_name} in
-               LONG_MAX|SSIZE_MAX)
+               
LONG_MAX|UINT_MAX|INT_MAX|SHRT_MAX|SSIZE_MAX|WORD_BIT|LONG_BIT|PTHREAD_*)
                        x=
                        ;;
                *)      eval x='$'CONF_const_${conf_name}
@@ -1091,7 +1103,11 @@ do       eval name=\"'$'CONF_name_$key\"
 ${head}
 #include <stdio.h>
 #include <sys/types.h>
+#include <sys/uio.h>
 #include <limits.h>
+#if defined(__linux__)
+#include <linux/limits.h>
+#endif
 #include <unistd.h>$systeminfo$headers
 ${tail}
 int
@@ -1105,7 +1121,11 @@ main()
                                        *)      cat > $tmp.c <<!
 ${head}
 #include <sys/types.h>
+#include <sys/uio.h>
 #include <limits.h>
+#if defined(__linux__)
+#include <linux/limits.h>
+#endif
 #include <unistd.h>$systeminfo$headers
 ${tail}
 ${script}
@@ -1249,7 +1269,11 @@ printf("#endif\n");
                                *)      cat > $tmp.c <<!
 ${head}
 #include <sys/types.h>
+#include <sys/uio.h>
 #include <limits.h>
+#if defined(__linux__)
+#include <linux/limits.h>
+#endif
 #include <unistd.h>$systeminfo$headers
 ${tail}
 ${script}
@@ -1322,7 +1346,7 @@ ${script}
                *[lLuU])
                        case $LL_suffix in
                        ??)     case $conf_limit in
-                               *[!lL][lL]|*[!lL][lL][uU])
+                               *[0-9a-fA-F][lL]|*[0-9a-fA-F][uU][lL])
                                        conf_limit=${conf_limit}L
                                        ;;
                                esac
@@ -1357,7 +1381,7 @@ ${script}
                *[lLuU])
                        case $LL_suffix in
                        ??)     case $conf_minmax in
-                               *[!lL][lL]|*[!lL][lL][uU])
+                               *[0-9a-fA-F][lL]|*[0-9a-fA-F][uU][lL])
                                        conf_minmax=${conf_minmax}L
                                        ;;
                                esac
@@ -1533,7 +1557,11 @@ esac
 cat <<!
 ${head}
 #include <sys/types.h>
+#include <sys/uio.h>
 #include <limits.h>
+#if defined(__linux__)
+#include <linux/limits.h>
+#endif
 #include <unistd.h>$systeminfo$headers
 ${tail}
 #include "${base}.h"
--- src/lib/libast/misc/getcwd.c
+++ src/lib/libast/misc/getcwd.c        2007-09-12 15:11:22.000000000 +0000
@@ -142,7 +142,7 @@ getcwd(char* buf, size_t len)
        };
 
        if (buf && !len) ERROR(EINVAL);
-       if (fs3d(FS3D_TEST) && (namlen = mount(".", dots, 
FS3D_GET|FS3D_VIEW|FS3D_SIZE(sizeof(dots)), NiL)) > 1 && namlen < sizeof(dots))
+       if (fs3d(FS3D_TEST) && (namlen = mount(".", dots, 
FS3D_FSTYPE(FS3D_GET|FS3D_VIEW|FS3D_SIZE(sizeof(dots))), NiL)) > 1 && namlen < 
sizeof(dots))
        {
                p = dots;
        easy:
--- src/lib/libast/misc/fs3d.c
+++ src/lib/libast/misc/fs3d.c  2007-09-12 15:12:17.000000000 +0000
@@ -48,11 +48,11 @@ fs3d(register int op)
         * get the current setting
         */
 
-       if (!fsview && mount("", "", 0, NiL))
+       if (!fsview && mount("", "", FS3D_FSTYPE(0), NiL))
                goto nope;
-       if (FS3D_op(op) == FS3D_OP_INIT && mount(FS3D_init, NiL, FS3D_VIEW, 
NiL))
+       if (FS3D_op(op) == FS3D_OP_INIT && mount(FS3D_init, "", 
FS3D_FSTYPE(FS3D_VIEW), NiL))
                goto nope;
-       if (mount(on, val, FS3D_VIEW|FS3D_GET|FS3D_SIZE(sizeof(val)), NiL))
+       if (mount(on, val, 
FS3D_FSTYPE(FS3D_VIEW|FS3D_GET|FS3D_SIZE(sizeof(val))), NiL))
                goto nope;
        if (v = strchr(val, ' ')) v++;
        else v = val;
@@ -79,7 +79,7 @@ fs3d(register int op)
                        v = 0;
                        break;
                }
-               if (v && mount(v, NiL, FS3D_VIEW, NiL))
+               if (v && mount(v, "", FS3D_FSTYPE(FS3D_VIEW), NiL))
                        goto nope;
        }
        fsview = 1;
--- src/lib/libast/path/pathkey.c
+++ src/lib/libast/path/pathkey.c       2007-09-12 15:12:47.000000000 +0000
@@ -93,7 +93,7 @@ pathkey(char* key, char* attr, const cha
                 * 3D
                 */
 
-               if (fs3d(FS3D_TEST) && (c = mount(path, tmp, 
FS3D_GET|FS3D_ALL|FS3D_SIZE(PATH_MAX), NiL)) > 1 && c < PATH_MAX)
+               if (fs3d(FS3D_TEST) && (c = mount(path, tmp, 
FS3D_FSTYPE(FS3D_GET|FS3D_ALL|FS3D_SIZE(PATH_MAX)), NiL)) > 1 && c < PATH_MAX)
                        path = tmp;
 
                /*
--- src/lib/libast/include/fs3d.h
+++ src/lib/libast/include/fs3d.h       2007-09-12 15:08:51.000000000 +0000
@@ -95,7 +95,17 @@
 #define FS3D_SIZE(n)   ((n)<<4)
 #define FS3D_SIZEOF(n) ((n)>>4)
 
+#if _sys_mount
+#include <sys/mount.h>
+#if defined(__linux__)
+#define FS3D_FSTYPE(a) "",(a)
+#else
+#define FS3D_FSTYPE(a) (a)
+#endif
+#else
 extern int             mount(const char*, char*, int, void*);
+#define FS3D_FSTYPE(a) (a)
+#endif
 
 #if _BLD_ast && defined(__EXPORT__)
 #define extern         __EXPORT__

Reply via email to