From maechler at stat.math.ethz.ch  Tue Jul 11 12:13:59 2006
From: maechler at stat.math.ethz.ch (Martin Maechler)
Date: Tue, 11 Jul 2006 12:13:59 +0200
Subject: [Rd] invalid alignment error in R-2.4.0
In-Reply-To: <Pine.LNX.4.64.0607111048300.12437@gannet.stats.ox.ac.uk>
References: <83E43F77-928F-4315-B311-0002B276A1F5@soc.soton.ac.uk>
	<17587.24696.569438.600090@stat.math.ethz.ch>
	<34CDD1D4-4F13-4411-8638-0E48451100D2@soc.soton.ac.uk>
	<17587.28594.327548.726315@stat.math.ethz.ch>
	<Pine.LNX.4.64.0607111048300.12437@gannet.stats.ox.ac.uk>
Message-ID: <17587.31207.103793.846045@stat.math.ethz.ch>

>>>>> "BDR" == Prof Brian Ripley <ripley at stats.ox.ac.uk>
>>>>>     on Tue, 11 Jul 2006 10:54:15 +0100 (BST) writes:

    BDR> On Tue, 11 Jul 2006, Martin Maechler wrote:
    >> Hi Robin,
    >> 
    >> thanks for the extra info.  I have no clue what the problem
    >> might be.
    >> 
    >> But from R-level debugging (and the R traceback you wrote
    >> originally),
    >> I assume you could trigger the problem already by a simple
    >> 
    >> median(rep(1000, 10))
    >> 
    >> is that the case? If yes, please follow up on R-devel.

    BDR> I don't see why you assume so: 
    BDR> there are multitudinous paths through  qsort.

yes, but I had Robin's data (*) and used debug(hist.default) :
diff(breaks) *was* identical to rep(1000, 10)  for the data
Robin posted.

    >> In any case, let's wait for others (Mac specialists and/or other
    >> R-core members) to voice ideas.

    BDR> I checked this under valgrind, which normally shows up such errors, and 
    BDR> found nothing, even with gctorture on (and valgrind instrumentation of 
    BDR> R's memory management on).

    BDR> You used the dput and Robin used load(), so presumably on not exactly the 
    BDR> same object.  


ahh yes, good point...
(*) hence means I only had the dput() version of his data.

    BDR> I think Robin needs to test what he actually gave us, to be 
    BDR> sure.  If that is the case, I suspect the compiler.



    >> Martin
    >> 
    >> 
    >> 
    >> >>>>> "Robin" == Robin Hankin <r.hankin at noc.soton.ac.uk>
    >> >>>>>     on Tue, 11 Jul 2006 10:04:34 +0100 writes:
    >> 
    Robin> Hi Martin
    Robin> On 11 Jul 2006, at 09:25, Martin Maechler wrote:
    >> 
    >> >> I assume this is specific to your installation of R-devel
    >> >> (R-2.4.0 "unstable").  If I use your 'out',
    >> >> hist(out^4, col = "gray")
    >> >> works just fine consistently.
    >> >> 
    >> >> Could it be a compiler / linker mismatch
    >> >> on your Mac?  Also, can you run "under the debugger"
    >> >> 'R -d gdb' (from a commandline) ?
    >> >> 
    >> >> This should allow a traceback ('backtrace', abbreviated 'bt' in "gdb")
    >> >> of the C call stack.
    >> 
    >> 
    >> 
    Robin> transcript follows:
    >> 
    >> 
    Robin> octopus:~/scratch% ./Rd/R.framework/Versions/2.4/Resources/bin/R -d gdb
    Robin> GNU gdb 6.1-20040303 (Apple version gdb-434) (Wed Nov  2 17:28:16 GMT  
    Robin> 2005)
    Robin> Copyright 2004 Free Software Foundation, Inc.
    Robin> GDB is free software, covered by the GNU General Public License, and  
    Robin> you are
    Robin> welcome to change it and/or distribute copies of it under certain  
    Robin> conditions.
    Robin> Type "show copying" to see the conditions.
    Robin> There is absolutely no warranty for GDB.  Type "show warranty" for  
    Robin> details.
    Robin> This GDB was configured as "powerpc-apple-darwin"...Reading symbols  
    Robin> for shared libraries ... done
    >> 
    Robin> (gdb) R
    Robin> Starting program: /Users/rksh/scratch/Rd/R.framework/Versions/2.4/ 
    Robin> Resources/bin/exec/R
    Robin> Reading symbols for shared libraries ...................+ done
    >> 
    Robin> R version 2.4.0 Under development (unstable) (2006-07-09 r38523)
    Robin> Copyright (C) 2006 The R Foundation for Statistical Computing
    Robin> ISBN 3-900051-07-0
    >> 
    Robin> R is free software and comes with ABSOLUTELY NO WARRANTY.
    Robin> You are welcome to redistribute it under certain conditions.
    Robin> Type 'license()' or 'licence()' for distribution details.
    >> 
    Robin> R is a collaborative project with many contributors.
    Robin> Type 'contributors()' for more information and
    Robin> 'citation()' on how to cite R or R packages in publications.
    >> 
    Robin> Type 'demo()' for some demos, 'help()' for on-line help, or
    Robin> 'help.start()' for an HTML browser interface to help.
    Robin> Type 'q()' to quit R.
    >> 
    Robin> Reading symbols for shared  
    Robin> libraries ..........................................................  
    Robin> done
    Robin> Reading symbols for shared libraries . done
    Robin> Reading symbols for shared libraries . done
    >> >> load("~/f")
    >> >> hist(out^4)
    >> 
    Robin> Program received signal EXC_BAD_ACCESS, Could not access memory.
    Robin> Reason: KERN_PROTECTION_FAILURE at address: 0x00000012
    Robin> R_qsort (v=0x2855858, i=1, j=2) at qsort-body.c:126
    Robin> 126             vt = v[i + 1];
    Robin> (gdb) bt
    Robin> #0  R_qsort (v=0x2855858, i=1, j=2) at qsort-body.c:126
    Robin> #1  0x0111e5d4 in do_qsort (call=0x1d0ed04, op=0x1, args=0x1d0b7f8,  
    Robin> rho=0x4) at qsort.c:89
    Robin> #2  0x010c9a1c in do_internal (call=0x1d0b7f8, op=0x1, args=0x0,  
    Robin> env=0x1d0c494) at names.c:1091
    Robin> #3  0x01099bb4 in Rf_eval (e=0x1d0ec94, rho=0x1d0c494) at eval.c:425
    Robin> #4  0x0109ba10 in do_set (call=0x1d0fb78, op=0x180a390,  
    Robin> args=0x1d0fb94, rho=0x1d0c494) at eval.c:1337
    Robin> #5  0x01099bb4 in Rf_eval (e=0x1d0fb78, rho=0x1d0c494) at eval.c:425
    Robin> #6  0x0109bc60 in do_begin (call=0x1d0fb40, op=0x180a2cc,  
    Robin> args=0x1d0fb5c, rho=0x1d0c494) at eval.c:1101
    Robin> #7  0x01099bb4 in Rf_eval (e=0x1d0fb40, rho=0x1d0c494) at eval.c:425
    Robin> #8  0x01099bb4 in Rf_eval (e=0x1d0fa44, rho=0x1d0c494) at eval.c:425
    Robin> #9  0x0109ba10 in do_set (call=0x1d0f9f0, op=0x180a390,  
    Robin> args=0x1d0fa0c, rho=0x1d0c494) at eval.c:1337
    Robin> #10 0x01099bb4 in Rf_eval (e=0x1d0f9f0, rho=0x1d0c494) at eval.c:425
    Robin> #11 0x0109bc60 in do_begin (call=0x1d0f5e4, op=0x180a2cc,  
    Robin> args=0x1d0f9d4, rho=0x1d0c494) at eval.c:1101
    Robin> #12 0x01099bb4 in Rf_eval (e=0x1d0f5e4, rho=0x1d0c494) at eval.c:425
    Robin> #13 0x01099bb4 in Rf_eval (e=0x1d0f520, rho=0x1d0c494) at eval.c:425
    Robin> #14 0x0109bc60 in do_begin (call=0x1d10f18, op=0x180a2cc,  
    Robin> args=0x1d0f504, rho=0x1d0c494) at eval.c:1101
    Robin> #15 0x01099bb4 in Rf_eval (e=0x1d10f18, rho=0x1d0c494) at eval.c:425
    Robin> #16 0x0109d0ac in Rf_applyClosure (call=0x1d1353c, op=0x1d10d58,  
    Robin> arglist=0x1d0d2ec, rho=0x1d13830, suppliedenv=0x181d304) at eval.c:615
    Robin> #17 0x01099d94 in Rf_eval (e=0x1d1353c, rho=0x1d13830) at eval.c:456
    Robin> #18 0x0109b008 in Rf_DispatchOrEval (call=0x1d134cc, op=0x180b978,  
    Robin> generic=0x11d74d0 "[", args=0x1d13504, rho=0x1d13830, ans=0xbfffa248,  
    Robin> dropmissing=0, argsevald=0) at eval.c:1758
    Robin> #19 0x0115a828 in do_subset (call=0x1d134cc, op=0x180b978, args=0x0,  
    Robin> rho=0x1d13830) at subset.c:527
    Robin> #20 0x01099bb4 in Rf_eval (e=0x1d134cc, rho=0x1d13830) at eval.c:425
    Robin> #21 0x01099a5c in Rf_eval (e=0x1d118a0, rho=0x1d1192c) at eval.c:402
    Robin> #22 0x0109ae04 in Rf_evalList (el=0x1b4f9dc, rho=0x1d1192c) at eval.c: 
    Robin> 1417
    Robin> #23 0x010c9980 in do_internal (call=0x1b4f9dc, op=0x1,  
    Robin> args=0x1b4fa14, env=0x1d1192c) at names.c:1087
    Robin> #24 0x01099bb4 in Rf_eval (e=0x1b4fa30, rho=0x1d1192c) at eval.c:425
    Robin> #25 0x0109d0ac in Rf_applyClosure (call=0x1d13424, op=0x1b4fa84,  
    Robin> arglist=0x1d118bc, rho=0x1d13830, suppliedenv=0x181d304) at eval.c:615
    Robin> #26 0x01099d94 in Rf_eval (e=0x1d13424, rho=0x1d13830) at eval.c:456
    Robin> #27 0x0109ae7c in Rf_evalList (el=0x1d13408, rho=0x1d13830) at eval.c: 
    Robin> 1427
    Robin> #28 0x01099c04 in Rf_eval (e=0x1d143b0, rho=0x1d13830) at eval.c:435
    Robin> #29 0x0109bc60 in do_begin (call=0x1d14378, op=0x180a2cc,  
    Robin> args=0x1d14394, rho=0x1d13830) at eval.c:1101
    Robin> #30 0x01099bb4 in Rf_eval (e=0x1d14378, rho=0x1d13830) at eval.c:425
    Robin> #31 0x01099bb4 in Rf_eval (e=0x1d140f4, rho=0x1d13830) at eval.c:425
    Robin> #32 0x0109bc60 in do_begin (call=0x1d14654, op=0x180a2cc,  
    Robin> args=0x1d140d8, rho=0x1d13830) at eval.c:1101
    Robin> #33 0x01099bb4 in Rf_eval (e=0x1d14654, rho=0x1d13830) at eval.c:425
    Robin> #34 0x0109d0ac in Rf_applyClosure (call=0x1fa96bc, op=0x1d15a7c,  
    Robin> arglist=0x1d137dc, rho=0x1d39024, suppliedenv=0x181d304) at eval.c:615
    Robin> #35 0x01099d94 in Rf_eval (e=0x1fa96bc, rho=0x1d39024) at eval.c:456
    Robin> #36 0x0109ae7c in Rf_evalList (el=0x1fa96a0, rho=0x1d39024) at eval.c: 
    Robin> 1427
    Robin> #37 0x01099c04 in Rf_eval (e=0x1fa9668, rho=0x1d39024) at eval.c:435
    Robin> #38 0x0109ba10 in do_set (call=0x1fa95c0, op=0x180a390,  
    Robin> args=0x1fa95dc, rho=0x1d39024) at eval.c:1337
    Robin> #39 0x01099bb4 in Rf_eval (e=0x1fa95c0, rho=0x1d39024) at eval.c:425
    Robin> #40 0x0109bc60 in do_begin (call=0x1facdc0, op=0x180a2cc,  
    Robin> args=0x1fa95a4, rho=0x1d39024) at eval.c:1101
    Robin> #41 0x01099bb4 in Rf_eval (e=0x1facdc0, rho=0x1d39024) at eval.c:425
    Robin> #42 0x0109d0ac in Rf_applyClosure (call=0x1d3a2c4, op=0x1fad6f4,  
    Robin> arglist=0x1d3a040, rho=0x1d3a094, suppliedenv=0x1d3a21c) at eval.c:615
    Robin> #43 0x010cc7e0 in Rf_usemethod (generic=0x1f69540 "hist",  
    Robin> obj=0x1fad6f4, call=0x2, args=0x4, rho=0x1d3a094, callrho=0x181d2e8,  
    Robin> defrho=0x2aa59f8, ans=0xbfffe148) at objects.c:311
    Robin> #44 0x010ccb20 in do_usemethod (call=0x1d3af24, op=0x1,  
    Robin> args=0x1d3af40, env=0x1d3a094) at objects.c:395
    Robin> #45 0x01099bb4 in Rf_eval (e=0x1d3af24, rho=0x1d3a094) at eval.c:425
    Robin> #46 0x0109d0ac in Rf_applyClosure (call=0x1d3b724, op=0x1d3ab88,  
    Robin> arglist=0x1d3a040, rho=0x181d2e8, suppliedenv=0x181d304) at eval.c:615
    Robin> #47 0x01099d94 in Rf_eval (e=0x1d3b724, rho=0x181d2e8) at eval.c:456
    Robin> #48 0x010b7d30 in Rf_ReplIteration (rho=0x181d2e8, savestack=0,  
    Robin> browselevel=0, state=0xbfffed88) at main.c:254
    Robin> #49 0x010b7e88 in R_ReplConsole (rho=0x181d2e8, savestack=0,  
    Robin> browselevel=0) at main.c:302
    Robin> #50 0x010b8198 in run_Rmainloop () at main.c:913
    Robin> #51 0x00002cec in main (ac=42293336, av=0x1) at Rmain.c:33
    Robin> (gdb)
    >> 
    >> 
    Robin> --
    Robin> Robin Hankin
    Robin> Uncertainty Analyst
    Robin> National Oceanography Centre, Southampton
    Robin> European Way, Southampton SO14 3ZH, UK
    Robin> tel  023-8059-7743
    >> 
    Robin> ______________________________________________
    Robin> R-devel at r-project.org mailing list
    Robin> https://stat.ethz.ch/mailman/listinfo/r-devel
    >> 
    >> ______________________________________________
    >> R-devel at r-project.org mailing list
    >> https://stat.ethz.ch/mailman/listinfo/r-devel
    >> 
    >> 

    BDR> -- 
    BDR> Brian D. Ripley,                  ripley at stats.ox.ac.uk
    BDR> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
    BDR> University of Oxford,             Tel:  +44 1865 272861 (self)
    BDR> 1 South Parks Road,                     +44 1865 272866 (PA)
    BDR> Oxford OX1 3TG, UK                Fax:  +44 1865 272595



[Rd] invalid alignment error in R-2.4.0
Martin Maechler