Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: protect(): protection stack overflow #5546

Closed
xiaguoxin opened this issue Oct 11, 2019 · 5 comments
Closed

Error: protect(): protection stack overflow #5546

xiaguoxin opened this issue Oct 11, 2019 · 5 comments
Assignees
Labels

Comments

@xiaguoxin
Copy link

@xiaguoxin xiaguoxin commented Oct 11, 2019

System details

RStudio Edition : Desktop
RStudio Version : Version 1.2.1335
OS Version      : macOS 10.14.5
R Version       : 3.6.1
&
RStudio Edition : Server
RStudio Version : (might be) 1.1.463
OS Version      : Ubuntu Server 18.04.3 LTS
R Version       : 3.6.0

Steps to reproduce the problem

From fast single item lookup from list vs data.table vs hash

# Set seed to 42 to ensure repeatability
set.seed(42)

# Generate product ids
product_ids <- as.vector(
  outer(LETTERS[seq(1, 26, 1)],
        outer(outer(LETTERS[seq(1, 26, 1)], LETTERS[seq(1, 26, 1)], paste, sep=""),
              LETTERS[seq(1, 26, 1)], paste, sep = ""
        ), paste, sep = ""
  )
)

# Create test lookup data
test_lookup_list <- lapply(product_ids, function(id){
  return_list <- list(
    product_id = id,
    val_1 = rnorm(1),
    val_2 = rnorm(1),
    val_3 = rnorm(1),
    val_4 = rnorm(1),
    val_5 = rnorm(1),
    val_6 = rnorm(1),
    val_7 = rnorm(1),
    val_8 = rnorm(1)
  )
  return(return_list)
})

# Set names of items in list
names(test_lookup_list) <- sapply(test_lookup_list, function(elem) elem[['product_id']])

test_lookup_env <- list2env(test_lookup_list)

Describe the problem in detail

the sessionInfo:

Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux 9 (stretch)

Matrix products: default
BLAS/LAPACK: /usr/lib/libopenblasp-r0.2.19.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8   
 [6] LC_MESSAGES=C              LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_3.6.0 tools_3.6.0    packrat_0.5.0 

I've searched for that and there were many suggestion about start R using argument --max-ppsize=5000000, but it seems not working with many post complained, and I don't know how to do it for a RStudio Server.

If there's some suggestion, it will be very helpful.
Thank you.

@kevinushey
Copy link
Contributor

@kevinushey kevinushey commented Oct 23, 2019

To fix this, I think we should consider:

  1. Always using str.default() when building the Environment pane, so that we don't run arbitrary user-defined code on objects within; or

  2. Consider disabling the 'has null external pointer' checks.

If I recall correctly, those checks were initially added because, quite some time ago, some objects (S4 objects using igraph?) could segfault when str() was called. However, this has long since been fixed.

@dmurdoch
Copy link
Contributor

@dmurdoch dmurdoch commented Dec 19, 2019

This bug has shown up in https://stackoverflow.com/q/59414426/2554330 with a very simple way to reproduce:

h <- hash::hash(1:120000, 1:120000)
# Error: protect(): protection stack overflow

@pnacht
Copy link

@pnacht pnacht commented Dec 19, 2019

Unsure whether to post this as a separate issue, but using the oneliner above and running it twice causes RStudio to soft-crash.

After the first call, we get the protect() error once.

After repeating the call (immediately or after waiting an arbitrary amount of time), we get an infinite sequence of

h <- hash::hash(1:120000, 1:120000)
# Error: protect(): protection stack overflow

h <- hash::hash(1:120000, 1:120000)
# Error: protect(): protection stack overflow
# Error: promise already under evaluation: recursive default argument reference or earlier problems?
# Error: protect(): protection stack overflow
# Error: promise already under evaluation: recursive default argument reference or earlier problems?
# Error: protect(): protection stack overflow
# Error: promise already under evaluation: recursive default argument reference or earlier problems?

This effectively crashes RStudio: subsequent calls are ignored, "Restart R" makes the "Restarting R..." tab thing appear at the top of the screen and stay there, with no progress. and we can't close RStudio normally, only via the Task Manager.

@kevinushey
Copy link
Contributor

@kevinushey kevinushey commented Jul 12, 2021

Note: bigmemory is actually one case where this null pointer examination may be warranted: #8923

But invalid bigmemory objects are really quite brittle (even asking them how long they are will cause a segfault).

@astayleraz
Copy link
Contributor

@astayleraz astayleraz commented Jul 14, 2021

Verified in Version 1.5.192-1 ubuntu20 that I am not seeing this show Error: protect(): protection stack overflow if I have null external pointers set to off in the command palette. Closing issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants