Segmentation fault when using data.table::tables() and colorout
eddelbuettel opened this issue · 11 comments
Huge fan of colorout
here, but I think I just found a wart.
In non-interactive mode, my ~/.Rprofile
does not load it and all is well:
edd@rob:~$ Rscript -e 'library(data.table); D <- data.table(a=1:3, b=LETTERS[1:3]); tables(); cat("Alive and well\n")'
NAME NROW NCOL MB COLS KEY
1: D 3 2 0 a,b
Total: 0MB
Alive and well
edd@rob:~$
In R, however, we die with a segfault once we get to tables()
:
> library(data.table); D <- data.table(a=1:3, b=LETTERS[1:3]); tables(); cat("Alive and well\n")
data.table 1.14.0 using 6 threads (see ?getDTthreads). Latest news: r-datatable.com
edd@rob:~$
If I set the RSTUDIO
variable first to prevent colorout
from being load, all is well. Can you take a look?
I can't replicate the issue. I've got "Alive and well" in both the Rscript command line and running R interactively. I'm running R 4.0.4 on Ubuntu 20.10.
Note: I've built R from source and all packages are built from source.
Same -- R 4.0.4 (via the binary at CRAN built from my Debian package sources) under 20.10. Hm.
My ~/.Rprofile.d/colorout.R
is "yours" too, but possibly only I these colors. Not that it should matter.
## custom Nord theme thanks to https://github.com/jalvesaq/colorout/issues/27#issuecomment-599207290
if (requireNamespace("colorout", quietly=TRUE) && Sys.getenv("RSTUDIO") != "1") {
## General ----------------------------------------
#message("Hello, coloured world!")
colorout::setOutputColors(
index = '\x1b[38;2;76;86;106m',
normal = '\x1b[38;2;216;222;233m',
number = '\x1b[38;2;236;239;244m',
negnum = '\x1b[38;2;180;142;173m',
zero = '\x1b[38;2;136;192;208m', zero.limit = 0.01,
infinite = '\x1b[38;2;236;239;244m',
string = '\x1b[38;2;235;203;139m',
date = '\x1b[38;2;236;239;244m',
const = '\x1b[38;2;136;192;208m',
true = '\x1b[38;2;163;190;140m',
false = '\x1b[38;2;191;97;106m',
warn = '\x1b[38;2;235;203;139m',
stderror = '\x1b[38;2;191;97;106m', error = '\x1b[38;2;191;97;106m',
verbose = FALSE
)
## Custom patterns --------------------------------
## NOTE Do not copy all. Pick what you use/like.
## _ {data.table} ---------------------------------
colorout::addPattern('[0-9]*:', '\x1b[38;2;143;188;187m') # Row num
colorout::addPattern('---', '\x1b[38;2;76;86;106m') # Row splitter
colorout::addPattern('<[a-z]*>', '\x1b[38;2;143;188;187m') # Col class
## _ `str` ----------------------------------------
## Class
colorout::addPattern(' num ', '\x1b[38;2;143;188;187m')
colorout::addPattern(' int ', '\x1b[38;2;143;188;187m')
colorout::addPattern(' chr ', '\x1b[38;2;143;188;187m')
colorout::addPattern(' Factor ', '\x1b[38;2;143;188;187m')
colorout::addPattern(' Ord.factor ', '\x1b[38;2;143;188;187m')
colorout::addPattern(' logi ', '\x1b[38;2;143;188;187m')
colorout::addPattern('function ', '\x1b[38;2;143;188;187m')
colorout::addPattern(' dbl ', '\x1b[38;2;143;188;187m')
colorout::addPattern(' lgcl ', '\x1b[38;2;143;188;187m')
colorout::addPattern(' cplx ', '\x1b[38;2;143;188;187m')
## Misc
colorout::addPattern('$ ', '\x1b[38;2;76;86;106m')
## _ `str`, {mlr3} --------------------------------
## R6 field name
colorout::addPattern('* [A-z]*:', '\x1b[38;2;235;203;139m')
colorout::addPattern("* [A-z]* [A-z]*:", '\x1b[38;2;235;203;139m')
colorout::addPattern("* [A-z]* [A-z]* [A-z]*:", '\x1b[38;2;235;203;139m')
colorout::addPattern("* [A-z]* [A-z]* [A-z]* [A-z]*:", '\x1b[38;2;235;203;139m')
## So on...
}
Is there some tracing or debugging I could or should turn on? I have been using the same setup for a looong time, even checked the repo a few weeks back but it all seems stable.
Could be a fluke, could be me ... but just surprised me in some casual data.table
work.
You could try strace
. Colorout itself doesn't have any test. I added your code to my .Rprofile, but I still get "Alive and well".
strace
is hard around all of R. But my dotfiles tickle on interactive()
which is off in Rscript
or R -q -e
but I can override it for littler
and its r
. It ends in a lot of munmap()
. Here are the last two screenfuls:
openat(AT_FDCWD, "/usr/lib/R/library/tools/R/sysdata.rdx", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=212, ...}) = 0
read(3, "\37\213\10\0\0\0\0\0\0\3\213\340b```f`\1BfV \223\201\317\321/\3303>\302"..., 4096) = 212
close(3) = 0
stat("/usr/lib/R/library/tools/R/sysdata.rdx", {st_mode=S_IFREG|0644, st_size=212, ...}) = 0
openat(AT_FDCWD, "/usr/lib/R/library/tools/R/sysdata.rdx", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=212, ...}) = 0
read(3, "\37\213\10\0\0\0\0\0\0\3\213\340b```f`\1BfV \223\201\317\321/\3303>\302"..., 16384) = 212
read(3, "", 12288) = 0
lseek(3, 0, SEEK_CUR) = 212
read(3, "", 16384) = 0
close(3) = 0
stat("/usr/lib/R/library/tools/data/Rdata.rdb", 0x7fff9204cba0) = -1 ENOENT (No such file or directory)
brk(0x55bc2ca93000) = 0x55bc2ca93000
openat(AT_FDCWD, "/usr/lib/R/library/tools/R/tools.rdb", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=1913572, ...}) = 0
fstat(3, {st_mode=S_IFREG|0644, st_size=1913572, ...}) = 0
lseek(3, 1912832, SEEK_SET) = 1912832
read(3, "\227\203\256\262\"\254%c\230\313R\217\210n\255\4\3253\347\346[\225r\347UK~~\253\230<\205"..., 740) = 740
brk(0x55bc2cc67000) = 0x55bc2cc67000
lseek(3, 0, SEEK_SET) = 0
read(3, "\0\0\2\203x\234\235R\261n\3020\20\275\304qQ\20T\f\355\2\02300\21\25\21U\355\310\310"..., 1912832) = 1912832
read(3, "\227\203\256\262\"\254%c\230\313R\217\210n\255\4\3253\347\346[\225r\347UK~~\253\230<\205"..., 4096) = 740
close(3) = 0
brk(0x55bc2cc89000) = 0x55bc2cc89000
brk(0x55bc2ccab000) = 0x55bc2ccab000
brk(0x55bc2cccc000) = 0x55bc2cccc000
brk(0x55bc2cced000) = 0x55bc2cced000
brk(0x55bc2cd0e000) = 0x55bc2cd0e000
brk(0x55bc2cd2f000) = 0x55bc2cd2f000
brk(0x55bc2cd50000) = 0x55bc2cd50000
brk(0x55bc2cd71000) = 0x55bc2cd71000
brk(0x55bc2cd92000) = 0x55bc2cd92000
brk(0x55bc2cdb3000) = 0x55bc2cdb3000
stat("/usr/lib/R/library/tools/libs/tools.so", {st_mode=S_IFREG|0644, st_size=97344, ...}) = 0
lstat("/usr", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/usr/lib", {st_mode=S_IFDIR|0755, st_size=12288, ...}) = 0
lstat("/usr/lib/R", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/usr/lib/R/library", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/usr/lib/R/library/tools", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/usr/lib/R/library/tools/libs", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
openat(AT_FDCWD, "/usr/lib/R/library/tools/libs/tools.so", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\200N\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=97344, ...}) = 0
mmap(NULL, 100776, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f3f65c5a000
mprotect(0x7f3f65c5e000, 77824, PROT_NONE) = 0
mmap(0x7f3f65c5e000, 57344, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x4000) = 0x7f3f65c5e000
mmap(0x7f3f65c6c000, 16384, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x12000) = 0x7f3f65c6c000
mmap(0x7f3f65c71000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x16000) = 0x7f3f65c71000
close(3) = 0
mprotect(0x7f3f65c71000, 4096, PROT_READ) = 0
brk(0x55bc2cdd4000) = 0x55bc2cdd4000
brk(0x55bc2cdf5000) = 0x55bc2cdf5000
brk(0x55bc2ce17000) = 0x55bc2ce17000
getpid() = 2152238
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
getpid() = 2152238
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
futex(0x7f3fc8318460, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x7f3fc8318410, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x7f3fc83184e0, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x7f3fc8318490, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x7f3fc8318560, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x7f3fc83185e0, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x7f3fc8318590, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x7f3fc8318660, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x7f3fc83186e0, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x7f3fc8318760, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x7f3fc83187e0, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x7f3fc8318790, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x7f3fc8318860, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x7f3fc8318810, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x7f3fc83188e0, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x7f3fc8318890, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x7f3fc8318960, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x7f3fc8318910, FUTEX_WAKE_PRIVATE, 1) = 1
munmap(0x7f3fc3784000, 8392704) = 0
munmap(0x7f3fbaf83000, 8392704) = 0
munmap(0x7f3fb2782000, 8392704) = 0
munmap(0x7f3fa9f81000, 8392704) = 0
munmap(0x7f3fa1780000, 8392704) = 0
munmap(0x7f3f98f7f000, 8392704) = 0
munmap(0x7f3f9077e000, 8392704) = 0
munmap(0x7f3fbb784000, 134217728) = 0
munmap(0x7f3fb2f83000, 134217728) = 0
munmap(0x7f3faa782000, 134217728) = 0
munmap(0x7f3fa1f81000, 134217728) = 0
munmap(0x7f3f99780000, 134217728) = 0
munmap(0x7f3f90f7f000, 134217728) = 0
munmap(0x7f3f8877e000, 134217728) = 0
munmap(0x7f3f7ff7d000, 134217728) = 0
munmap(0x7f3f7777c000, 134217728) = 0
munmap(0x7f3f6ddb5000, 134217728) = 0
munmap(0x7f3f65cb5000, 134217728) = 0
exit_group(0) = ?
+++ exited with 0 +++
Let me try on another (similar) machine just in case.
Yes. let's close. The minimal example didn't replicate on a smaller laptop (same R, Ubuntu, ... ) after I setup a similar minimal ~/.R/profile.d
and its colourout.R
. Rebuilding data.table
doesn't do anything for me. Odd. But likely something else...
Thanks for the feedback. Please, reopen the issue if necessary.
Thanks for lending an ear, and the super-speedy replies. I will try bring the "small machine" setup closer to my main one, maybe it replicates there. Else files under Heisenbug...
Thanks as always for colorout
.
More completeness, I found the offending line, and it has (of course) nothing to do with colorour
. Sorry for making noise earlier.
Thanks for the feedback! I'm glad to know that colorout is still healthy.