Rdatatable / data.table

R's data.table package extends data.frame:
http://r-datatable.com
Mozilla Public License 2.0
3.62k stars 985 forks source link

Recursive list when list column is assigned a dt by reference #6488

Open rikivillalba opened 1 month ago

rikivillalba commented 1 month ago

This is somewhat related to #4877

library(data.table)
dt <- data.table(x = list(1,2,3))
dt[, y := .(list(dt))]
dt[, y]  
# Error: protect(): protection stack overflow

Since it is an obvious corner case, I'm not sure if it qualifies as bug or such situations must be managed with copy().

MichaelChirico commented 1 month ago

I would normally call this a bug & say "stop playing with fire" :)

But just yesterday #4890 shows how we can probably fix this pretty easily by checking if x's own address is among the return values & inducing copy() automatically if so.