Re: [Rd] Print bug for matrix(list(NA_complex_, ...))
> William Dunlap > on Wed, 3 Jun 2009 11:49:00 -0700 writes: > Changing the uninitialized 'w' to 'R_print.na_width' for > the complex NA code fixes up the valgrind complaints on > Linux and the bad behavior on Windows: [.] Thanks a lot, Bill, both for the diagnosis and the fix! I'll commit (a slight variation of) it to R-devel and R-patched. Martin __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Print bug for matrix(list(NA_complex_, ...))
Quick action, thanks! Does this also fix the spacing problem (at the end of my bug report)? -s On Wed, Jun 3, 2009 at 2:49 PM, William Dunlap wrote: > Changing the uninitialized 'w' to 'R_print.na_width' for the complex NA > code fixes up the valgrind complaints on Linux and the bad behavior > on Windows: > > === > --- print.c (revision 48703) > +++ print.c (working copy) > @@ -357,7 +357,7 @@ > formatComplex(x, 1, &wr, &dr, &er, &wi, &di, &ei, > 0); > if (ISNA(x[0].r) || ISNA(x[0].i)) > snprintf(pbuf, 115, "%s", > -EncodeReal(NA_REAL, w, 0, 0, OutDec)); > +EncodeReal(NA_REAL, R_print.na_width, > 0, 0, OutDec)); /* formatReal would set w=R_print.na_width,d=0,e=0 for > NA */ >else > snprintf(pbuf, 115, "%s", EncodeComplex(x[0], > wr, dr, er, wi, di, ei, OutDec)); > > E.g., the following prints go very quickly and don't have lots of > trailing > blanks. > > > val <- matrix(list(NA_complex_, 3, "A string", NA_complex_), 2,2) > > print(val) > [,1] [,2] > [1,] NA "A string" > [2,] 3NA > > print(val, na.print="") > [,1] > [1,] > [2,] 3 > [,2] > [1,] "A string" > [2,] > > Bill Dunlap > TIBCO Software Inc - Spotfire Division > wdunlap tibco.com > > > -Original Message----- > > From: r-devel-boun...@r-project.org > > [mailto:r-devel-boun...@r-project.org] On Behalf Of William Dunlap > > Sent: Wednesday, June 03, 2009 9:21 AM > > To: Martin Maechler; Wacek Kusnierczyk > > Cc: r-devel@r-project.org > > Subject: Re: [Rd] Print bug for matrix(list(NA_complex_, ...)) > > > > > > > From: William Dunlap > > > Sent: Wednesday, June 03, 2009 8:58 AM > > > To: 'Martin Maechler'; Wacek Kusnierczyk > > > Cc: r-devel@r-project.org > > > Subject: RE: [Rd] Print bug for matrix(list(NA_complex_, ...)) > > ... > > > > >> There is a bug in printing val <- > > > > matrix(list(NA_complex_,NA_complex_),1). > > ... > > > > >> Note that a large number of spaces are printed > > > instead of NA. > > > > > > > > vQ> on ubuntu 8.04 with r 2.10.0 r48703 there is almost > > > > no problem (still > > > > vQ> some unnecessary spaces): > > > > > > > > vQ> [,1] [,2] > > > > vQ> [1,]NANA > > > > > > > > thank you, Waclav. > > > > > > > > I don't see any unnecessary space (or other CPU problems), > > > > using another Linux variant (RHEL 5) > > > > in the three R version > > > > 2.9.0 , > > > > 2.9.0-patched (r48700) > > > > 2.10.0-devel (r48700) > > > > > > > > Can other Windows (or ...) users confirm problems in R 2.9.0 > > > > (or newer) ? > > > > > > I just tried it on 2.9.0 on the Windows GUI (RGui.exe) > > > and saw similar problems. When printing to the > > > command window, with either print(val) or show(val) it took > > > a very long time and put $'s at the ends of the lines > > > (indicating that there was text beyond the edge of the window). > > > I used sink() to put the output into a file and then print() and > > > show() acted quickly. The resulting file had 119 character > > > lines, consisting mainly of trailing blanks: > > > > > > > readLines("c:/temp/val.txt") # output of > > > print(val);show(val);str(val) > > > [1] " [,1] > > >" > > > [2] "[1,] > > >" > > > [3] " [,2] > > >" > > > [4] "[1,] > > >" > > > [5] " [,1] > > >" > > > [6] "[1,] > > >" > > > [7] " [,2] > > >
Re: [Rd] Print bug for matrix(list(NA_complex_, ...))
Changing the uninitialized 'w' to 'R_print.na_width' for the complex NA code fixes up the valgrind complaints on Linux and the bad behavior on Windows: === --- print.c (revision 48703) +++ print.c (working copy) @@ -357,7 +357,7 @@ formatComplex(x, 1, &wr, &dr, &er, &wi, &di, &ei, 0); if (ISNA(x[0].r) || ISNA(x[0].i)) snprintf(pbuf, 115, "%s", -EncodeReal(NA_REAL, w, 0, 0, OutDec)); +EncodeReal(NA_REAL, R_print.na_width, 0, 0, OutDec)); /* formatReal would set w=R_print.na_width,d=0,e=0 for NA */ else snprintf(pbuf, 115, "%s", EncodeComplex(x[0], wr, dr, er, wi, di, ei, OutDec)); E.g., the following prints go very quickly and don't have lots of trailing blanks. > val <- matrix(list(NA_complex_, 3, "A string", NA_complex_), 2,2) > print(val) [,1] [,2] [1,] NA "A string" [2,] 3NA > print(val, na.print="") [,1] [1,] [2,] 3 [,2] [1,] "A string" [2,] Bill Dunlap TIBCO Software Inc - Spotfire Division wdunlap tibco.com > -Original Message- > From: r-devel-boun...@r-project.org > [mailto:r-devel-boun...@r-project.org] On Behalf Of William Dunlap > Sent: Wednesday, June 03, 2009 9:21 AM > To: Martin Maechler; Wacek Kusnierczyk > Cc: r-devel@r-project.org > Subject: Re: [Rd] Print bug for matrix(list(NA_complex_, ...)) > > > > From: William Dunlap > > Sent: Wednesday, June 03, 2009 8:58 AM > > To: 'Martin Maechler'; Wacek Kusnierczyk > > Cc: r-devel@r-project.org > > Subject: RE: [Rd] Print bug for matrix(list(NA_complex_, ...)) > ... > > > >> There is a bug in printing val <- > > > matrix(list(NA_complex_,NA_complex_),1). > ... > > > >> Note that a large number of spaces are printed > > instead of NA. > > > > > > vQ> on ubuntu 8.04 with r 2.10.0 r48703 there is almost > > > no problem (still > > > vQ> some unnecessary spaces): > > > > > > vQ> [,1] [,2] > > > vQ> [1,]NANA > > > > > > thank you, Waclav. > > > > > > I don't see any unnecessary space (or other CPU problems), > > > using another Linux variant (RHEL 5) > > > in the three R version > > > 2.9.0 , > > > 2.9.0-patched (r48700) > > > 2.10.0-devel (r48700) > > > > > > Can other Windows (or ...) users confirm problems in R 2.9.0 > > > (or newer) ? > > > > I just tried it on 2.9.0 on the Windows GUI (RGui.exe) > > and saw similar problems. When printing to the > > command window, with either print(val) or show(val) it took > > a very long time and put $'s at the ends of the lines > > (indicating that there was text beyond the edge of the window). > > I used sink() to put the output into a file and then print() and > > show() acted quickly. The resulting file had 119 character > > lines, consisting mainly of trailing blanks: > > > > > readLines("c:/temp/val.txt") # output of > > print(val);show(val);str(val) > > [1] " [,1] > >" > > [2] "[1,] > >" > > [3] " [,2] > >" > > [4] "[1,] > >" > > [5] " [,1] > >" > > [6] "[1,] > >" > > [7] " [,2] > >" > > [8] "[1,] > >
Re: [Rd] Print bug for matrix(list(NA_complex_, ...))
> From: William Dunlap > Sent: Wednesday, June 03, 2009 8:58 AM > To: 'Martin Maechler'; Wacek Kusnierczyk > Cc: r-devel@r-project.org > Subject: RE: [Rd] Print bug for matrix(list(NA_complex_, ...)) ... > > >> There is a bug in printing val <- > > matrix(list(NA_complex_,NA_complex_),1). ... > > >> Note that a large number of spaces are printed > instead of NA. > > > > vQ> on ubuntu 8.04 with r 2.10.0 r48703 there is almost > > no problem (still > > vQ> some unnecessary spaces): > > > > vQ> [,1] [,2] > > vQ> [1,]NANA > > > > thank you, Waclav. > > > > I don't see any unnecessary space (or other CPU problems), > > using another Linux variant (RHEL 5) > > in the three R version > > 2.9.0 , > > 2.9.0-patched (r48700) > > 2.10.0-devel (r48700) > > > > Can other Windows (or ...) users confirm problems in R 2.9.0 > > (or newer) ? > > I just tried it on 2.9.0 on the Windows GUI (RGui.exe) > and saw similar problems. When printing to the > command window, with either print(val) or show(val) it took > a very long time and put $'s at the ends of the lines > (indicating that there was text beyond the edge of the window). > I used sink() to put the output into a file and then print() and > show() acted quickly. The resulting file had 119 character > lines, consisting mainly of trailing blanks: > > > readLines("c:/temp/val.txt") # output of > print(val);show(val);str(val) > [1] " [,1] >" > [2] "[1,] >" > [3] " [,2] >" > [4] "[1,] >" > [5] " [,1] >" > [6] "[1,] >" > [7] " [,2] >" > [8] "[1,] >" > [9] "List of 2" > > [10] " $ : cplx NA" > > [11] " $ : cplx NA" > > [12] " - attr(*, \"dim\")= int [1:2] 1 2" > > > nchar(readLines("c:/temp/val.txt")) > [1] 119 119 119 119 119 119 119 119 9 12 12 32 > > On Linux, using yesterday's 2.9.0, valgrind shows lots > of 'depends on uninitialized value' problems that could > explain the Linux-Windows difference in behavior: > > > val<-matrix(list(NA_complex_,NA_complex_),1) > > val > ==24859== Conditional jump or move depends on uninitialised value(s) > ==24859==at 0x6F7E2F: vfprintf (in /lib/tls/libc-2.3.4.so) > ==24859==by 0x7177A5: vsnprintf (in /lib/tls/libc-2.3.4.so) > ==24859==by 0x6FF4E1: snprintf (in /lib/tls/libc-2.3.4.so) > ==24859==by 0x809DDC1: Rf_EncodeReal (printutils.c:179) > ==24859==by 0x8099AA9: Rf_PrintValueRec (print.c:359) > ==24859==by 0x809A124: Rf_PrintValueEnv (print.c:956) > ==24859==by 0x80584CA: Rf_ReplIteration (main.c:261) > ==24859==by 0x8058572: R_ReplConsole (main.c:306) > ==24859==by 0x8058BB8: run_Rmainloop (main.c:967) > ==24859==by 0x8056A70: main (Rmain.c:33) Here is the traceback when it enters Rf_EncodeReal: (gdb) where #0 Rf_EncodeReal (x=nan(0x007a2), w=168381312, d=0, e=0, cdec=46 '.') at printutils.c:160 #1 0x08099aaa in Rf_PrintValueRec (s=0x9f4a4a8, env=0x9e4cc90) at print.c:359 #2 0x0809a125 in Rf_PrintValueEnv (s=0x9f4a4a8, env=0x9e4cc90) at print.c:956 #3 0x080584cb in Rf_ReplIteration (rho=0x9e4cc90, savestack=0, b
Re: [Rd] Print bug for matrix(list(NA_complex_, ...))
> -Original Message- > From: r-devel-boun...@r-project.org > [mailto:r-devel-boun...@r-project.org] On Behalf Of Martin Maechler > Sent: Wednesday, June 03, 2009 2:37 AM > To: Wacek Kusnierczyk > Cc: r-devel@r-project.org > Subject: Re: [Rd] Print bug for matrix(list(NA_complex_, ...)) > > >>>>> "vQ" == Wacek Kusnierczyk > > >>>>> on Wed, 03 Jun 2009 10:43:25 +0200 writes: > > vQ> Stavros Macrakis wrote: > >> In R 2.8.0 on Windows (tested both under ESS and under > R Console in case > >> there was an I/O issue) > >> > >> There is a bug in printing val <- > matrix(list(NA_complex_,NA_complex_),1). > >> > >> > >>> dput(val) > >>> > >> structure(list(NA_complex_, NA_complex_), .Dim = 1:2) > >> > >> > >>> print(val) > >>> > >> > >> [,1] > >> > >> [1,] > >> > >> > >> [,2] > >> > >> [1,] > >> > >> > >> Note that a large number of spaces are printed instead of NA. > > vQ> on ubuntu 8.04 with r 2.10.0 r48703 there is almost > no problem (still > vQ> some unnecessary spaces): > > vQ> [,1] [,2] > vQ> [1,]NANA > > thank you, Waclav. > > I don't see any unnecessary space (or other CPU problems), > using another Linux variant (RHEL 5) > in the three R version > 2.9.0 , > 2.9.0-patched (r48700) > 2.10.0-devel (r48700) > > Can other Windows (or ...) users confirm problems in R 2.9.0 > (or newer) ? I just tried it on 2.9.0 on the Windows GUI (RGui.exe) and saw similar problems. When printing to the command window, with either print(val) or show(val) it took a very long time and put $'s at the ends of the lines (indicating that there was text beyond the edge of the window). I used sink() to put the output into a file and then print() and show() acted quickly. The resulting file had 119 character lines, consisting mainly of trailing blanks: > readLines("c:/temp/val.txt") # output of print(val);show(val);str(val) [1] " [,1] " [2] "[1,] " [3] " [,2] " [4] "[1,] " [5] " [,1] " [6] "[1,] " [7] " [,2] " [8] "[1,] " [9] "List of 2" [10] " $ : cplx NA" [11] " $ : cplx NA" [12] " - attr(*, \"dim\")= int [1:2] 1 2" > nchar(readLines("c:/temp/val.txt")) [1] 119 119 119 119 119 119 119 119 9 12 12 32 On Linux, using yesterday's 2.9.0, valgrind shows lots of 'depends on uninitialized value' problems that could explain the Linux-Windows difference in behavior: > val<-matrix(list(NA_complex_,NA_complex_),1) > val ==24859== Conditional jump or move depends on uninitialised value(s) ==24859==at 0x6F7E2F: vfprintf (in /lib/tls/libc-2.3.4.so) ==24859==by 0x7177A5: vsnprintf (in /lib/tls/libc-2.3.4.so) ==24859==by 0x6FF4E1: snprintf (in /lib/tls/libc-2.3.4.so) ==24859==by 0x809DDC1: Rf_EncodeReal (printutils.c:179) ==24859==by 0x8099AA9: Rf_PrintValueRec (print.c:359) ==24859==by 0x809A124: Rf_PrintValueEnv (print.c:956) ==24859==by 0x80584CA: Rf_ReplIteration (main.c:261) ==24859==by 0x8058572: R_ReplConsole (main.c:306) ==24859==by 0x8058BB8: run_Rmainloop (main.c:967) ==24859==by 0x8056A70: main (Rmain.c:33) ==24859== ==24859== Conditional jump or move depends on uninitialised value(s) ==24859==at 0x6F7E44: vfprintf (in /lib/tls/libc-2.3.4.so) ==24859==by 0x7177A5: vsnprintf (in /lib/tls/libc-2.3.4.so) ==24859==by 0x6FF4E1: snprintf (in /lib/tls/libc-2.3.4.so) ==24859==by 0x809DDC1: Rf_EncodeReal (printutils.c:179) ==24859==by 0x8099AA9: Rf_PrintValueRec (print.c:359) ==24859==by 0x809A124: Rf_PrintValueEnv (print.c:956) ==24859==by 0x80584CA: Rf_ReplIteration (main.c:261) ==24859==by 0x8058572: R_ReplConsole (main.c:306) ==24859==by 0x8058BB8: run_Rmainloop (main.c:967) ==24859==by 0x8056A70: main (Rmain.c:33) ==24859== ==24859== Conditional jump or move depends on uninitialised value(s) ==24859==at 0x6F7E4C: vfprintf (in /lib/tls/libc-2.3.4.so) ==24859==by 0x7177A5: vsnprintf (in /lib/tls/libc-2.3.4.so) ==24859==by 0x6FF4E1: snprintf (in /lib/tls/libc-2.3.4.so) ==24859==by 0x809DDC1: Rf_EncodeReal (printutils.c:179) ==24859==by 0x8099AA9: Rf_PrintValueRec (print.c:359) ==24859==by 0x809A124: Rf_PrintValueEnv (print.c:956) ==24859==by 0x80584CA: Rf_ReplIteration (main.c:261) ==24859==by 0x
Re: [Rd] Print bug for matrix(list(NA_complex_, ...))
> "vQ" == Wacek Kusnierczyk > on Wed, 03 Jun 2009 10:43:25 +0200 writes: vQ> Stavros Macrakis wrote: >> In R 2.8.0 on Windows (tested both under ESS and under R Console in case >> there was an I/O issue) >> >> There is a bug in printing val <- matrix(list(NA_complex_,NA_complex_),1). >> >> >>> dput(val) >>> >> structure(list(NA_complex_, NA_complex_), .Dim = 1:2) >> >> >>> print(val) >>> >> >> [,1] >> >> [1,] >> >> >> [,2] >> >> [1,] >> >> >> Note that a large number of spaces are printed instead of NA. vQ> on ubuntu 8.04 with r 2.10.0 r48703 there is almost no problem (still vQ> some unnecessary spaces): vQ> [,1] [,2] vQ> [1,]NANA thank you, Waclav. I don't see any unnecessary space (or other CPU problems), using another Linux variant (RHEL 5) in the three R version 2.9.0 , 2.9.0-patched (r48700) 2.10.0-devel (r48700) Can other Windows (or ...) users confirm problems in R 2.9.0 (or newer) ? Regards, Martin Maechler >> Compare the >> unproblematic real case: >> >> print(structure(list(NA_real_, NA_real_), .Dim = 1:2)) >> [,1] [,2] >> [1,] NA NA >> >> Also, when printed in the read-eval-print loop, printing takes a very very >> long time: >> >> >>> proc.time(); matrix(list(NA_complex_,NA_complex_),1); proc.time() >>> >> user system elapsed >> 74.350.09 329.45 >> >> [,1] >> >> [1,] >> >> >> [,2] >> >> [1,] >> >> user system elapsed >> 92.630.15 347.86 >> >> 18 seconds runtime! >> vQ> user system elapsed vQ> 0.648 0.056 155.843 vQ> [,1] [,2] vQ> [1,] NA NA vQ> user system elapsed vQ> 0.648 0.056 155.843 vQ> vQ vQ> __ vQ> R-devel@r-project.org mailing list vQ> https://stat.ethz.ch/mailman/listinfo/r-devel __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Print bug for matrix(list(NA_complex_, ...))
Stavros Macrakis wrote: > In R 2.8.0 on Windows (tested both under ESS and under R Console in case > there was an I/O issue) > > There is a bug in printing val <- matrix(list(NA_complex_,NA_complex_),1). > > >> dput(val) >> > structure(list(NA_complex_, NA_complex_), .Dim = 1:2) > > >> print(val) >> > > [,1] > > [1,] > > > [,2] > > [1,] > > > Note that a large number of spaces are printed instead of NA. on ubuntu 8.04 with r 2.10.0 r48703 there is almost no problem (still some unnecessary spaces): [,1] [,2] [1,]NANA > Compare the > unproblematic real case: > > print(structure(list(NA_real_, NA_real_), .Dim = 1:2)) > [,1] [,2] > [1,] NA NA > > Also, when printed in the read-eval-print loop, printing takes a very very > long time: > > >> proc.time(); matrix(list(NA_complex_,NA_complex_),1); proc.time() >> >user system elapsed > 74.350.09 329.45 > > [,1] > > [1,] > > > [,2] > > [1,] > >user system elapsed > 92.630.15 347.86 > > 18 seconds runtime! > user system elapsed 0.648 0.056 155.843 [,1] [,2] [1,] NA NA user system elapsed 0.648 0.056 155.843 vQ __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Print bug for matrix(list(NA_complex_, ...))
In R 2.8.0 on Windows (tested both under ESS and under R Console in case there was an I/O issue) There is a bug in printing val <- matrix(list(NA_complex_,NA_complex_),1). > dput(val) structure(list(NA_complex_, NA_complex_), .Dim = 1:2) > print(val) [,1] [1,] [,2] [1,] Note that a large number of spaces are printed instead of NA. Compare the unproblematic real case: print(structure(list(NA_real_, NA_real_), .Dim = 1:2)) [,1] [,2] [1,] NA NA Also, when printed in the read-eval-print loop, printing takes a very very long time: > proc.time(); matrix(list(NA_complex_,NA_complex_),1); proc.time() user system elapsed 74.350.09 329.45 [,1] [1,] [,2] [1,] user system elapsed 92.630.15 347.86 18 seconds runtime! This does not happen with an explicit print: > proc.time(); print(structure(list(NA_complex_,NA_complex_), .Dim = 1:2)); proc.time() user system elapsed 92.630.15 355.90 [,1] [1,] [,2] [1,] user system elapsed 92.770.15 356.05 -- A perhaps related problem is that the NA's are not properly aligned in some cases: > structure(list(NaN, NA_complex_, NA_real_, NA_complex_, NA_real_, NA_complex_, NA_real_, NA_complex_, NA_complex_, NA_complex_, NaN, NA_complex_, NA_complex_, NA_complex_), .Dim = c(2L, 7L)) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [1,] NaN NA NA NA NA NaN NA [2,] NA NA NA NA NANA NA It is perhaps hard to see this in email, but there is an extra space in front of the NAs at [1,7], [2,1], and [2,6]. Please let me know if you need additional information to troubleshoot this problem. -s [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel