From kevin.hendricks at sympatico.ca  Sat Jun  3 17:51:17 2006
From: kevin.hendricks at sympatico.ca (Kevin B. Hendricks)
Date: Sat, 3 Jun 2006 11:51:17 -0400
Subject: [Rd] More on bug 7924
Message-ID: <97A17BA5-1020-4A50-A0FE-8BAB84A7915A@sympatico.ca>

Hi,

Again, sorry for the length of this post.  Once I get my new office I  
will get a website set up on my work machine and will simply post a  
link to the log since I doubt many people are truly interested in  
these logs.

To further analyze what is happening, I added my own routine in  
main.c called DEBUG_SET_NAMED and then redefined the SET_NAMED macro  
to use it and then rebuilt R.

I then fired up R under a fresh environment  and running under GDB  
and set a breakpoint at my DEBUG_SET_NAMED and at compute_identical

 > call1 <- Quote(f(arg[[1]], arg[[1]], arg[[1]]))

So running this statement shows that SET_NAMED was run on 5 objects  
of type 13,16,10,3 and with the last one being a type 6.

In all cases, but the type 6 object, named was set to 2.  For the  
type 6 object, named was set to 1

Breakpoint 1, DEBUG_SET_NAMED (x=0x85cfd8, v=2)
     at ../../../r-devel/r-devel/R/src/main/main.c:1444
1444      (x->sxpinfo.named) = v;
$1 = 0x85cfd8
$2 = {sxpinfo = {type = 13, obj = 0, named = 2, gp = 0, mark = 1,  
debug = 0,
     trace = 0, fin = 0, gcgen = 0, gccls = 1}, attrib = 0x508818,
   gengc_next_node = 0x6db278, gengc_prev_node = 0x8442b8, u =  
{primsxp = {
       offset = 2}, symsxp = {pname = 0x2, value = 0x230002acc2,
       internal = 0x21000090}, listsxp = {carval = 0x2, cdrval =  
0x230002acc2,
       tagval = 0x21000090}, envsxp = {frame = 0x2, enclos =  
0x230002acc2,
       hashtab = 0x21000090}, closxp = {formals = 0x2, body =  
0x230002acc2,
       env = 0x21000090}, promsxp = {value = 0x2, expr = 0x230002acc2,
       env = 0x21000090}}}
#0  DEBUG_SET_NAMED (x=0x85cfd8, v=2)    at ../../../r-devel/r-devel/ 
R/src/main/main.c:1444
#1  0x00002aaaaab67b04 in Rf_eval (e=0x570348, rho=0x9eb5f0)     
at ../../../r-devel/r-devel/R/src/main/eval.c:389

Breakpoint 1, DEBUG_SET_NAMED (x=0x87da18, v=2)   at ../../../r-devel/ 
r-devel/R/src/main/main.c:1444
1444      (x->sxpinfo.named) = v;
$3 = 0x87da18
$4 = {sxpinfo = {type = 16, obj = 0, named = 2, gp = 0, mark = 1,  
debug = 0,
     trace = 0, fin = 0, gcgen = 0, gccls = 1}, attrib = 0x508818,
   gengc_next_node = 0x8403f8, gengc_prev_node = 0x87d868, u =  
{primsxp = {
       offset = 1}, symsxp = {pname = 0x1, value = 0x1185c48,
       internal = 0x2000000a}, listsxp = {carval = 0x1, cdrval =  
0x1185c48,
       tagval = 0x2000000a}, envsxp = {frame = 0x1, enclos = 0x1185c48,
       hashtab = 0x2000000a}, closxp = {formals = 0x1, body = 0x1185c48,
       env = 0x2000000a}, promsxp = {value = 0x1, expr = 0x1185c48,
       env = 0x2000000a}}}
#0  DEBUG_SET_NAMED (x=0x87da18, v=2)    at ../../../r-devel/r-devel/ 
R/src/main/main.c:1444
#1  0x00002aaaaab67b04 in Rf_eval (e=0x545ed0, rho=0x9eb5f0)     
at ../../../r-devel/r-devel/R/src/main/eval.c:389

Breakpoint 1, DEBUG_SET_NAMED (x=0x822bf8, v=2)    at ../../../r- 
devel/r-devel/R/src/main/main.c:1444
1444      (x->sxpinfo.named) = v;
$5 = 0x822bf8
$6 = {sxpinfo = {type = 10, obj = 0, named = 2, gp = 0, mark = 1,  
debug = 0,
     trace = 0, fin = 0, gcgen = 0, gccls = 1}, attrib = 0x508818,
   gengc_next_node = 0x661208, gengc_prev_node = 0x840428, u =  
{primsxp = {
       offset = 1}, symsxp = {pname = 0x1, value = 0x1, internal =  
0x20000090},
     listsxp = {carval = 0x1, cdrval = 0x1, tagval = 0x20000090},  
envsxp = {
       frame = 0x1, enclos = 0x1, hashtab = 0x20000090}, closxp = {
       formals = 0x1, body = 0x1, env = 0x20000090}, promsxp = {value  
= 0x1,
       expr = 0x1, env = 0x20000090}}}
#0  DEBUG_SET_NAMED (x=0x822bf8, v=2)
     at ../../../r-devel/r-devel/R/src/main/main.c:1444
#1  0x00002aaaaab67b04 in Rf_eval (e=0x570230, rho=0x9eb5f0)
     at ../../../r-devel/r-devel/R/src/main/eval.c:389

Breakpoint 1, DEBUG_SET_NAMED (x=0x5d02d0, v=2)
     at ../../../r-devel/r-devel/R/src/main/main.c:1444
1444      (x->sxpinfo.named) = v;
$7 = 0x5d02d0
$8 = {sxpinfo = {type = 3, obj = 0, named = 2, gp = 0, mark = 1,  
debug = 0,
     trace = 0, fin = 0, gcgen = 0, gccls = 0}, attrib = 0x508818,
   gengc_next_node = 0x5d0378, gengc_prev_node = 0xb843c0, u =  
{primsxp = {
       offset = 5711720}, symsxp = {pname = 0x572768, value = 0x5745c0,
       internal = 0x648910}, listsxp = {carval = 0x572768, cdrval =  
0x5745c0,
       tagval = 0x648910}, envsxp = {frame = 0x572768, enclos =  
0x5745c0,
       hashtab = 0x648910}, closxp = {formals = 0x572768, body =  
0x5745c0,
       env = 0x648910}, promsxp = {value = 0x572768, expr = 0x5745c0,
       env = 0x648910}}}
#0  DEBUG_SET_NAMED (x=0x5d02d0, v=2)
     at ../../../r-devel/r-devel/R/src/main/main.c:1444
#1  0x00002aaaaab67b04 in Rf_eval (e=0x570188, rho=0x9eb5f0)
     at ../../../r-devel/r-devel/R/src/main/eval.c:389


Breakpoint 1, DEBUG_SET_NAMED (x=0x9ebe58, v=1)    at ../../../r- 
devel/r-devel/R/src/main/main.c:1444
1444      (x->sxpinfo.named) = v;
$9 = 0x9ebe58
$10 = {sxpinfo = {type = 6, obj = 0, named = 0, gp = 0, mark = 0,  
debug = 0,
     trace = 0, fin = 0, gcgen = 0, gccls = 0}, attrib = 0x508818,
   gengc_next_node = 0x9ebe90, gengc_prev_node = 0x9ebe20, u =  
{primsxp = {
       offset = 10663048}, symsxp = {pname = 0xa2b488, value = 0x9ecd90,
       internal = 0x508818}, listsxp = {carval = 0xa2b488, cdrval =  
0x9ecd90,
       tagval = 0x508818}, envsxp = {frame = 0xa2b488, enclos =  
0x9ecd90,
       hashtab = 0x508818}, closxp = {formals = 0xa2b488, body =  
0x9ecd90,
       env = 0x508818}, promsxp = {value = 0xa2b488, expr = 0x9ecd90,
       env = 0x508818}}}
#0  DEBUG_SET_NAMED (x=0x9ebe58, v=1)
     at ../../../r-devel/r-devel/R/src/main/main.c:1444
#1  0x00002aaaaab6b5d3 in do_set (call=0x9ec1d8, op=Variable "op" is  
not available.)
     at ../../../r-devel/r-devel/R/src/main/eval.c:1353



Then I assigned call2

 >
 > call2 <- Quote(f(arg[[1]]))[c(1,2,2,2)]


Again a variety of objects (types 14, 14, 14, 14, 19)  has named set  
to 2, all except for the final object (again type = 6) that had named  
set to 1



Breakpoint 1, DEBUG_SET_NAMED (x=0xf9b808, v=2)
     at ../../../r-devel/r-devel/R/src/main/main.c:1444
1444      (x->sxpinfo.named) = v;
$11 = 0xf9b808
$12 = {sxpinfo = {type = 14, obj = 0, named = 0, gp = 0, mark = 0,  
debug = 0,
     trace = 0, fin = 0, gcgen = 0, gccls = 1}, attrib = 0x508818,
   gengc_next_node = 0xf9b868, gengc_prev_node = 0xf9b7d8, u =  
{primsxp = {
       offset = 1}, symsxp = {pname = 0x1, value = 0x3ff0000000000000,
       internal = 0x21000109}, listsxp = {carval = 0x1,
       cdrval = 0x3ff0000000000000, tagval = 0x21000109}, envsxp = {
       frame = 0x1, enclos = 0x3ff0000000000000, hashtab = 0x21000109},
     closxp = {formals = 0x1, body = 0x3ff0000000000000, env =  
0x21000109},
     promsxp = {value = 0x1, expr = 0x3ff0000000000000, env =  
0x21000109}}}
#0  DEBUG_SET_NAMED (x=0xf9b808, v=2)
     at ../../../r-devel/r-devel/R/src/main/main.c:1444
#1  0x00002aaaaab676ff in Rf_eval (e=0xf9b808, rho=0x547858)
     at ../../../r-devel/r-devel/R/src/main/eval.c:362

Breakpoint 1, DEBUG_SET_NAMED (x=0xf9b868, v=2)
     at ../../../r-devel/r-devel/R/src/main/main.c:1444
1444      (x->sxpinfo.named) = v;
$13 = 0xf9b868
$14 = {sxpinfo = {type = 14, obj = 0, named = 0, gp = 0, mark = 0,  
debug = 0,
     trace = 0, fin = 0, gcgen = 0, gccls = 1}, attrib = 0x508818,
   gengc_next_node = 0xf9b898, gengc_prev_node = 0xf9b808, u =  
{primsxp = {
       offset = 1}, symsxp = {pname = 0x1, value = 0x4000000000000000,
       internal = 0x2000000e}, listsxp = {carval = 0x1,
       cdrval = 0x4000000000000000, tagval = 0x2000000e}, envsxp = {
       frame = 0x1, enclos = 0x4000000000000000, hashtab = 0x2000000e},
     closxp = {formals = 0x1, body = 0x4000000000000000, env =  
0x2000000e},
     promsxp = {value = 0x1, expr = 0x4000000000000000, env =  
0x2000000e}}}
#0  DEBUG_SET_NAMED (x=0xf9b868, v=2)
     at ../../../r-devel/r-devel/R/src/main/main.c:1444
#1  0x00002aaaaab676ff in Rf_eval (e=0xf9b868, rho=0x547858)
     at ../../../r-devel/r-devel/R/src/main/eval.c:362

Breakpoint 1, DEBUG_SET_NAMED (x=0xf9b898, v=2)
     at ../../../r-devel/r-devel/R/src/main/main.c:1444
1444      (x->sxpinfo.named) = v;
$15 = 0xf9b898
$16 = {sxpinfo = {type = 14, obj = 0, named = 0, gp = 0, mark = 0,  
debug = 0,
     trace = 0, fin = 0, gcgen = 0, gccls = 1}, attrib = 0x508818,
   gengc_next_node = 0xf98b48, gengc_prev_node = 0xf9b868, u =  
{primsxp = {
       offset = 1}, symsxp = {pname = 0x1, value = 0x4000000000000000,
       internal = 0x0}, listsxp = {carval = 0x1, cdrval =  
0x4000000000000000,
       tagval = 0x0}, envsxp = {frame = 0x1, enclos =  
0x4000000000000000,
       hashtab = 0x0}, closxp = {formals = 0x1, body =  
0x4000000000000000,
       env = 0x0}, promsxp = {value = 0x1, expr = 0x4000000000000000,
       env = 0x0}}}
#0  DEBUG_SET_NAMED (x=0xf9b898, v=2)
     at ../../../r-devel/r-devel/R/src/main/main.c:1444
#1  0x00002aaaaab676ff in Rf_eval (e=0xf9b898, rho=0x547858)
     at ../../../r-devel/r-devel/R/src/main/eval.c:362

Breakpoint 1, DEBUG_SET_NAMED (x=0xf98b48, v=2)
     at ../../../r-devel/r-devel/R/src/main/main.c:1444
1444      (x->sxpinfo.named) = v;
$17 = 0xf98b48
$18 = {sxpinfo = {type = 14, obj = 0, named = 0, gp = 0, mark = 0,  
debug = 0,
     trace = 0, fin = 0, gcgen = 0, gccls = 1}, attrib = 0x508818,
   gengc_next_node = 0xf98c08, gengc_prev_node = 0xf9b898, u =  
{primsxp = {
       offset = 1}, symsxp = {pname = 0x1, value = 0x4000000000000000,
       internal = 0x21000010}, listsxp = {carval = 0x1,
       cdrval = 0x4000000000000000, tagval = 0x21000010}, envsxp = {
       frame = 0x1, enclos = 0x4000000000000000, hashtab = 0x21000010},
     closxp = {formals = 0x1, body = 0x4000000000000000, env =  
0x21000010},
     promsxp = {value = 0x1, expr = 0x4000000000000000, env =  
0x21000010}}}
#0  DEBUG_SET_NAMED (x=0xf98b48, v=2)
     at ../../../r-devel/r-devel/R/src/main/main.c:1444
#1  0x00002aaaaab676ff in Rf_eval (e=0xf98b48, rho=0x547858)
     at ../../../r-devel/r-devel/R/src/main/eval.c:362

Breakpoint 1, DEBUG_SET_NAMED (x=0x143a918, v=2)
     at ../../../r-devel/r-devel/R/src/main/main.c:1444
1444      (x->sxpinfo.named) = v;
$19 = 0x143a918
$20 = {sxpinfo = {type = 19, obj = 0, named = 0, gp = 0, mark = 0,  
debug = 0,
     trace = 0, fin = 0, gcgen = 0, gccls = 3}, attrib = 0x508818,
   gengc_next_node = 0x143a960, gengc_prev_node = 0x143a8d0, u =  
{primsxp = {
       offset = 4}, symsxp = {pname = 0x4, value = 0x508818,
       internal = 0x508818}, listsxp = {carval = 0x4, cdrval = 0x508818,
       tagval = 0x508818}, envsxp = {frame = 0x4, enclos = 0x508818,
       hashtab = 0x508818}, closxp = {formals = 0x4, body = 0x508818,
       env = 0x508818}, promsxp = {value = 0x4, expr = 0x508818,
       env = 0x508818}}}
#0  DEBUG_SET_NAMED (x=0x143a918, v=2)
     at ../../../r-devel/r-devel/R/src/main/main.c:1444
#1  0x00002aaaaac25dcd in do_subset_dflt (call=0x9e98f0, op=Variable  
"op" is not available.)
     at ../../../r-devel/r-devel/R/src/main/subset.c:160

Breakpoint 1, DEBUG_SET_NAMED (x=0x9e8db0, v=1)
     at ../../../r-devel/r-devel/R/src/main/main.c:1444
1444      (x->sxpinfo.named) = v;
$21 = 0x9e8db0
$22 = {sxpinfo = {type = 6, obj = 0, named = 0, gp = 0, mark = 0,  
debug = 0,
     trace = 0, fin = 0, gcgen = 0, gccls = 0}, attrib = 0x508818,
   gengc_next_node = 0x9e8de8, gengc_prev_node = 0x9e8d78, u =  
{primsxp = {
       offset = 10663048}, symsxp = {pname = 0xa2b488, value = 0x9e8d78,
       internal = 0x508818}, listsxp = {carval = 0xa2b488, cdrval =  
0x9e8d78,
       tagval = 0x508818}, envsxp = {frame = 0xa2b488, enclos =  
0x9e8d78,
       hashtab = 0x508818}, closxp = {formals = 0xa2b488, body =  
0x9e8d78,
       env = 0x508818}, promsxp = {value = 0xa2b488, expr = 0x9e8d78,
       env = 0x508818}}}
#0  DEBUG_SET_NAMED (x=0x9e8db0, v=1)
     at ../../../r-devel/r-devel/R/src/main/main.c:1444
#1  0x00002aaaaab6b5d3 in do_set (call=0x9e9998, op=Variable "op" is  
not available.)
     at ../../../r-devel/r-devel/R/src/main/eval.c:1353



Now when I run the call to identical, you can see that both of the  
type 6 objects created by the assignments to call1 and call2 have  
named set to 2 by Rf_eval in the way to compute_identical


 > identical(call1, call2)



Breakpoint 1, DEBUG_SET_NAMED (x=0x9ebe58, v=2)
     at ../../../r-devel/r-devel/R/src/main/main.c:1444
1444      (x->sxpinfo.named) = v;
$23 = 0x9ebe58
$24 = {sxpinfo = {type = 6, obj = 0, named = 1, gp = 0, mark = 0,  
debug = 0,
     trace = 0, fin = 0, gcgen = 0, gccls = 0}, attrib = 0x508818,
   gengc_next_node = 0x9ebe90, gengc_prev_node = 0x9ebe20, u =  
{primsxp = {
       offset = 10663048}, symsxp = {pname = 0xa2b488, value = 0x9ecd90,
       internal = 0x508818}, listsxp = {carval = 0xa2b488, cdrval =  
0x9ecd90,
       tagval = 0x508818}, envsxp = {frame = 0xa2b488, enclos =  
0x9ecd90,
       hashtab = 0x508818}, closxp = {formals = 0xa2b488, body =  
0x9ecd90,
       env = 0x508818}, promsxp = {value = 0xa2b488, expr = 0x9ecd90,
       env = 0x508818}}}
#0  DEBUG_SET_NAMED (x=0x9ebe58, v=2)
     at ../../../r-devel/r-devel/R/src/main/main.c:1444
#1  0x00002aaaaab67b04 in Rf_eval (e=0x56ca30, rho=0x9e91a0)
     at ../../../r-devel/r-devel/R/src/main/eval.c:389


Breakpoint 1, DEBUG_SET_NAMED (x=0x9e8db0, v=2)
     at ../../../r-devel/r-devel/R/src/main/main.c:1444
1444      (x->sxpinfo.named) = v;
$25 = 0x9e8db0
$26 = {sxpinfo = {type = 6, obj = 0, named = 1, gp = 0, mark = 0,  
debug = 0,
     trace = 0, fin = 0, gcgen = 0, gccls = 0}, attrib = 0x508818,
   gengc_next_node = 0x9e8de8, gengc_prev_node = 0x9e8d78, u =  
{primsxp = {
       offset = 10663048}, symsxp = {pname = 0xa2b488, value = 0x9e8d78,
       internal = 0x508818}, listsxp = {carval = 0xa2b488, cdrval =  
0x9e8d78,
       tagval = 0x508818}, envsxp = {frame = 0xa2b488, enclos =  
0x9e8d78,
       hashtab = 0x508818}, closxp = {formals = 0xa2b488, body =  
0x9e8d78,
       env = 0x508818}, promsxp = {value = 0xa2b488, expr = 0x9e8d78,
       env = 0x508818}}}
#0  DEBUG_SET_NAMED (x=0x9e8db0, v=2)
     at ../../../r-devel/r-devel/R/src/main/main.c:1444
#1  0x00002aaaaab67b04 in Rf_eval (e=0x92d5d0, rho=0x9e91a0)
     at ../../../r-devel/r-devel/R/src/main/eval.c:389



Now finally the breakpoint at compute_identical was reached and you  
can see that the type 6 objects that had their named value changed  
from 1 to 2 are in fact the top level objects being sent to identical  
but now they have named set to 2


Breakpoint 2, compute_identical (x=0x9ebe58, y=0x9e8db0)
     at ../../../r-devel/r-devel/R/src/main/identical.c:53
53      {

(gdb) print *x
$27 = {sxpinfo = {type = 6, obj = 0, named = 2, gp = 0, mark = 0,  
debug = 0,
     trace = 0, fin = 0, gcgen = 0, gccls = 0}, attrib = 0x508818,
   gengc_next_node = 0x9ebe90, gengc_prev_node = 0x9ebe20, u =  
{primsxp = {
       offset = 10663048}, symsxp = {pname = 0xa2b488, value = 0x9ecd90,
       internal = 0x508818}, listsxp = {carval = 0xa2b488, cdrval =  
0x9ecd90,
       tagval = 0x508818}, envsxp = {frame = 0xa2b488, enclos =  
0x9ecd90,
       hashtab = 0x508818}, closxp = {formals = 0xa2b488, body =  
0x9ecd90,
       env = 0x508818}, promsxp = {value = 0xa2b488, expr = 0x9ecd90,
       env = 0x508818}}}

(gdb) print *y
$29 = {sxpinfo = {type = 6, obj = 0, named = 2, gp = 0, mark = 0,  
debug = 0,
     trace = 0, fin = 0, gcgen = 0, gccls = 0}, attrib = 0x508818,
   gengc_next_node = 0x9e8de8, gengc_prev_node = 0x9e8d78, u =  
{primsxp = {
       offset = 10663048}, symsxp = {pname = 0xa2b488, value = 0x9e8d78,
       internal = 0x508818}, listsxp = {carval = 0xa2b488, cdrval =  
0x9e8d78,
       tagval = 0x508818}, envsxp = {frame = 0xa2b488, enclos =  
0x9e8d78,
       hashtab = 0x508818}, closxp = {formals = 0xa2b488, body =  
0x9e8d78,
       env = 0x508818}, promsxp = {value = 0xa2b488, expr = 0x9e8d78,
       env = 0x508818}}}



So I think this does confirm that the call to identical does indeed  
change the top level objects named from 1 to 2.


I still need to learn more about how objects are made and what an  
object of LANGSXP type really is and what the proper setting is for  
named for an object that is a list of other objects whose named  
values are set to  0, 1, or 2 respectively.

My guess is just before a final objects is assigned, we might have to  
walk the tree of subobjects in some way to make sure all of the named  
values are sane.  The code seems to be setting this to 2 in lots of  
places and some seem like quick patches to other problems.  I still  
don't understand why call1 and call2 when used as arguments to  
identical() and not in assignment statements can have their named  
values changed.  I would expect nothing to be changed in call1 or  
call2 py passing them to a function like identical.

So I will keep looking.

FWIW, it might be a good idea to set up DEBUG_SET_NAMED and other  
accessor functions so that when built under -DDEBUG_ACCESSORS that  
they are used to replace the macros spreadout all over the place in  
the code.  A change like that would be easy to do if anyone feels it  
would be worthwhile.

Hope this helps.

Kevin



[Rd] More on bug 7924
Kevin B. Hendricks