Glenn Fowler wrote:
>
> beta source tarballs for the { INIT ast-ksh ast-open } packages
> have been posted at
>
> http://www.research.att.com/sw/download/beta/
The new test in functions.sh causes a crash when ksh93 is compiled with
optimisation enabled (e.g. /opt/SUNWspro/bin/cc -xO3 or better). The
weired part is that this does not happen when I compile without
optimisation.
Standalone testcase looks like this:
-- snip --
f()
{
print -u2 $1
if (($1>1))
then x=${ f $(($1-1)) ; } || exit 1
fi
return 0
}
f 300 && print ok
print "done"
-- snip --
The top of the stack trace looks like this:
-- snip --
program terminated by signal SEGV (no mapping at the fault address)
Current function is sfvprintf
129 int decimal = 0, thousand = 0;
(dbx) where
=>[1] sfvprintf(f = 0x1, form = (nil), args = (nil)), line 129 in
"sfvprintf.c"
[2] sfprintf(f = 0x100346eb0, form = 0x10021bb20 "%lld", ... = 0x11,
...), line 48 in "sfprintf.c"
[3] comsubst(mp = 0x100346920, t = 0x100612650, type = 1), line 1882
in "macro.c"
[4] varsub(mp = 0x100346920), line 1082 in "macro.c"
[5] copyto(mp = 0x100346920, endch = 0, newquote = 0), line 582 in
"macro.c"
[6] sh_macexpand(shp = 0x10032d520, argp = 0x1006125f0, arghead =
0xffffffff7f805468, flag = 0), line 235 in "macro.c"
[7] arg_expand(shp = 0x10032d520, argp = 0x1006125f0, argchain =
0xffffffff7f805468, flag = 0), line 852 in "args.c"
[8] sh_argbuild(shp = 0x10032d520, nargs = 0xffffffff7f8057c4, comptr
= 0x1006125b0, flag = 0), line 723 in "args.c"
[9] sh_exec(t = 0x1006125b0, flags = 1), line 704 in "xec.c"
[10] sh_subshell(t = 0x1006125b0, flags = 1, comsub = 2), line 537 in
"subshell.c"
[11] comsubst(mp = 0x100346920, t = 0x1006125b0, type = 2), line 1951
in "macro.c"
[12] varsub(mp = 0x100346920), line 1829 in "macro.c"
[13] copyto(mp = 0x100346920, endch = 0, newquote = 0), line 582 in
"macro.c"
[14] sh_mactrim(shp = 0x10032d520, str = 0x100369c41 "x=${ f $(($1-1))
; }", mode = -1), line 173 in "macro.c"
[15] nv_setlist(arg = 0x100369c30, flags = 131584), line 324 in
"name.c"
[16] sh_exec(t = 0x100369c60, flags = 0), line 815 in "xec.c"
[17] sh_exec(t = 0x100369da0, flags = 0), line 1522 in "xec.c"
[18] sh_exec(t = 0x100369b80, flags = 0), line 1768 in "xec.c"
[19] sh_exec(t = 0x100369f20, flags = 0), line 1504 in "xec.c"
[20] b_dot_cmd(n = 0, argv = 0x100612548, extra = 0x10032d9f0), line
289 in "misc.c"
[21] sh_funct(shp = 0x10032d520, np = 0x10034d250, argn = 2, argv =
0x100612548, envlist = (nil), execflg = 1), line 2653 in "xec.c"
[22] sh_exec(t = 0x1006124c0, flags = 1), line 1118 in "xec.c"
[23] sh_subshell(t = 0x1006124c0, flags = 1, comsub = 2), line 537 in
"subshell.c"
[24] comsubst(mp = 0x100346920, t = 0x1006124c0, type = 2), line 1951
in "macro.c"
[25] varsub(mp = 0x100346920), line 1829 in "macro.c"
[snip]
(dbx) print sh
sh = {
options = {
v = (4398047559680U, 0, 0, 0)
}
var_tree = 0x10034fbd0
fun_tree = 0x100352560
alias_tree = 0x100350b60
bltin_tree = 0x1003524c0
topscope = 0xffffffff7f8096b0
inlineno = 10
exitval = 0
trapnote = '\0'
shcomp = '\0'
subshell = 476
st = {
prevst = 0xffffffff7f80db50
dolc = 1
dolv = 0x100555fd8
cmdname = 0x1006124b1 "f"
filename = 0x100369a30
"/home/test001/ksh93/ast_ksh_20081212/build_sparc_64bit_readfix/test.sh"
funname = 0x10034d288 "f"
lineno = 0
save_tree = 0x10034fbd0
self = 0xffffffff7f8096b0
var_local = 0x10034fbd0
staklist = (nil)
states = 0
breakcnt = 0
execbrk = 0
loopcnt = 0
firstline = 0
optindex = 1
optnum = 0
tmout = 0
optchar = 0
opterror = 0
ioset = 0
trapmax = 0
trap = ((nil), (nil), (nil), (nil), (nil))
trapcom = 0x10034d2f0
otrapcom = (nil)
timetrap = (nil)
real_fun = (nil)
}
lim = {
arg_max = 2096640
open_max = 256
clk_tck = 100
child_max = 29995
ngroups_max = 16
posix_version = 'X'
posix_jobcontrol = '\001'
fs3d = '\0'
}
stk = 0x10032f308
heredocs = (nil)
funlog = (nil)
fdptrs = 0x1003474e0
savexit = 0
lastarg = 0x100352c70
"../build_sparc_64bit/arch/sol11.sun4/bin/ksh"
lastpath = (nil)
path_err = 0
track_tree = 0x100350c00
var_base = 0x10034fbd0
namespace = (nil)
last_table = (nil)
prev_table = (nil)
outpool = 0x10034a560
timeout = 0
curenv = 476
jobenv = 0
infd = 10
nextprompt = 1
bltin_nnodes = 64
bltin_nodes = 0x10034edc0
bltin_cmds = 0x100350ca0
posix_fun = (nil)
outbuff = 0x10034aa30 ""
errbuff = 0x10034ca40 "125\n"
prompt = (nil)
shname = 0x1003675f0 "test.sh"
shpath = 0x100361bf0
"/home/test001/ksh93/ast_ksh_20081212/build_sparc_64bit/arch/sol11.sun4/bin/ksh"
user = (nil)
comdiv = 0xffffffffffffffff "<bad address 0xffffffff>"
prefix = (nil)
jmplist = 0xffffffff7f8059d8
sigmsg = 0x10034d4e0
oldexit = 0
userid = 1000U
euserid = 1000U
groupid = 100U
egroupid = 100U
pid = 16990
bckpid = 0
cpid = 0
spid = 0
ppid = 16813
topfd = 0
sigmax = 48
savesig = 0
sigflag = 0x10034d490 ""
intrap = '\0'
login_sh = '\0'
lastbase = '\0'
forked = '\0'
binscript = '\0'
deftype = '\0'
funload = '\0'
used_pos = '\001'
universe = '\0'
winch = '\0'
indebug = '\0'
lastsig = '\0'
readscript = (nil)
inpipe = (nil)
outpipe = (nil)
cpipe = (-1, 0)
coutpipe = -1
inuse_bits = 0
envlist = 0x100369c30
arglist = (nil)
fn_depth = 0
fn_reset = 0
dot_depth = 476
hist_depth = 0
xargmin = 0
xargmax = 0
xargexit = 0
nenv = 0
mask = 18U
nforks = 0
env = (nil)
init_context = 0x10034e7a0
mac_context = 0x100346920
lex_context = 0x1003469c0
arg_context = 0x100346970
ed_context = 0x100346aa0
job_context = (nil)
pathlist = 0x10036a1e0
defpathlist = (nil)
cdpathlist = (nil)
argaddr = (nil)
optlist = (nil)
global = {
prevst = (nil)
dolc = 0
dolv = 0xffffffff7ffffa70
cmdname = 0x100367620 "test.sh"
filename = 0x100367680
"/home/test001/ksh93/ast_ksh_20081212/build_sparc_64bit_readfix/test.sh"
funname = 0x10034d288 "f"
lineno = 9
save_tree = 0x10034fbd0
self = 0x10032d870
var_local = (nil)
staklist = (nil)
states = 0
breakcnt = 0
execbrk = 0
loopcnt = 0
firstline = 0
optindex = 1
optnum = 0
tmout = 0
optchar = 0
opterror = 0
ioset = 0
trapmax = 0
trap = ((nil), (nil), (nil), (nil), (nil))
trapcom = 0x10034d2f0
otrapcom = (nil)
timetrap = (nil)
real_fun = (nil)
}
checkbase = {
buff = (0, -2147487983, 4295107028, -2147487535, 4295104236, 0,
0, 0, 0, 0, 0, 0)
prev = (nil)
topfd = 0
mode = 12
olist = (nil)
err = {
context = (nil)
errors = 0
flags = 0
line = 0
warnings = 0
file = (nil)
id = 0x100367620 "test.sh"
}
}
userinit = (nil)
bltinfun = (nil)
bltindata = {
shp = 0x10032d520
ptr = (nil)
version = 20071012
shrun = 0x100096b78 = &sh_run()
shtrap = 0x10002bef8 = &sh_trap()
shexit = 0x10002c398 = &sh_exit()
shbltin = 0x1000ca3b0 = &sh_addbuiltin()
notify = '\0'
sigset = '\0'
nosfio = '\0'
bnode = 0x1003514f0
vnode = (nil)
data = (nil)
flags = 0
shgetenv = 0x1000698b8 = &getenv()
shsetenv = 0x100069ad0 = &_ast_setenviron()
invariant = 1
}
waitevent = (nil)
cur_line = (nil)
rcfile = (nil)
login_files = 0x1003414f8
offsets = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
sftable = 0x100347cf0
fdstatus = 0x1003473d0 "3^B3^X"
pwd = 0x100353e40
"/home/test001/ksh93/ast_ksh_20081212/build_sparc_64bit_readfix"
hist_ptr = (nil)
jmpbuffer = 0x10032d940
mktype = (nil)
strbuf = 0x100346eb0
strbuf2 = (nil)
last_root = 0x100352560
prev_root = (nil)
fpathdict = (nil)
typedict = 0x100352750
ifstable = ""
sigruntime = ")0"
test = 0
offoptions = {
v = (0, 0, 0, 0)
}
glob_options = {
v = (0, 0, 0, 0)
}
typeinit = (nil)
stats = 0x100352b80
nvfun = {
disc = (nil)
nofree = '\001'
subshell = '\0'
dsize = 0
next = (nil)
last = 0x10032d520 ""
type = (nil)
}
}
-- snip --
It seems this problem is not caused by stack overflow (the stack has 8MB
for 64bit SPARC applications on Solaris 11 (e.g. exhausting a 8MB stack
would mean that each function would require 27k of stack (which is AFAIK
unlikely))) ... something else is going wrong... ;-(
----
Bye,
Roland
--
__ . . __
(o.\ \/ /.o) [email protected]
\__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer
/O /==\ O\ TEL +49 641 3992797
(;O/ \/ \O;)
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users