# Complaints about slot "mode" rearing their head again

**URL:** https://discourse.mc-stan.org/t/complaints-about-slot-mode-rearing-their-head-again/11027
**Category:** RStan
**Created:** [September 17, 2019, 7:37pm UTC](https://discourse.mc-stan.org/t/complaints-about-slot-mode-rearing-their-head-again/11027 "2019-09-17T19:37:39Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![jjramsey](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jjramsey/32/3319_2.png) [@jjramsey](https://discourse.mc-stan.org/u/jjramsey)
#### Post date: [September 17, 2019, 7:37pm UTC](https://discourse.mc-stan.org/t/complaints-about-slot-mode-rearing-their-head-again/11027/1 "2019-09-17T19:37:39Z")

</div>

ETA: Further discussion probably best moved to this thread: [Parallel chains not working; different behavior in RStudio and R from Terminal](https://discourse.mc-stan.org/t/parallel-chains-not-working-different-behavior-in-rstudio-and-r-from-terminal/11038)

When running a model with RStan using 4 chains in parallel, I get this error:

```
Error in FUN(X[[i]], ...) : 
  trying to get slot "mode" from an object of a basic class ("NULL") with no slots
Calls: sampling -> sampling -> .local -> sapply -> lapply -> FUN

```

The same model used to work with RStan and still runs with PyStan just fine.

It looks like this problem has shown up before: [R 3.5.1 complains about slot "mode"](https://discourse.mc-stan.org/t/r-3-5-1-complains-about-slot-mode/4971)

However, this time it’s happening with R 3.6.1 and RStan 2.18.2.

Any ideas on fixes or workarounds?

---

<div class="post-metadata">

### Author: ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)
#### Post date: [September 17, 2019, 7:43pm UTC](https://discourse.mc-stan.org/t/complaints-about-slot-mode-rearing-their-head-again/11027/2 "2019-09-17T19:43:10Z")

</div>

The slot mode thing is a red herring. The sampler returned `NULL`, which means it aborted. There is usually a message about why if you run it with `chains = 1`.

---

<div class="post-metadata">

### Author: ![jjramsey](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jjramsey/32/3319_2.png) [@jjramsey](https://discourse.mc-stan.org/u/jjramsey)
#### Post date: [September 17, 2019, 7:57pm UTC](https://discourse.mc-stan.org/t/complaints-about-slot-mode-rearing-their-head-again/11027/3 "2019-09-17T19:57:07Z")

</div>

Huh, now it just aborted almost right away. It used to be that at least a couple chains ran:

```
Chain 1: 
Chain 1: Gradient evaluation took 7e-05 seconds
Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 0.7 seconds.
Chain 1: Adjust your expectations accordingly!
Chain 1: 
Chain 1: 
Abort trap: 6

```

ETA: That was when running R at the Terminal. When running from RStudio, it actually works – but only if `chains` = 1. Otherwise, this is the output:

```
SAMPLING FOR MODEL 'jc' NOW (CHAIN 1).
Chain 1: 
Chain 1: Gradient evaluation took 0.00011 seconds
Chain 1: 1000 transitions using 10 leapfrog steps per transition would take 1.1 seconds.
Chain 1: Adjust your expectations accordingly!
Chain 1: 
Chain 1: 
Error in unserialize(socklist[[n]]) : error reading from connection

SAMPLING FOR MODEL 'jc' NOW (CHAIN 2).
Chain 2: 
Chain 2: Gradient evaluation took 0.000152 seconds
Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 1.52 seconds.
Chain 2: Adjust your expectations accordingly!
Chain 2: 
Chain 2: 
Chain 2: Iteration: 1 / 2000 [0%] (Warmup)

SAMPLING FOR MODEL 'jc' NOW (CHAIN 3).
Chain 3: 
Chain 3: Gradient evaluation took 7.9e-05 seconds
Chain 3: 1000 transitions using 10 leapfrog steps per transition would take 0.79 seconds.
Chain 3: Adjust your expectations accordingly!
Chain 3: 
Chain 3: 

SAMPLING FOR MODEL 'jc' NOW (CHAIN 4).
Chain 4: 
Chain 4: Gradient evaluation took 0.000107 seconds
Chain 4: 1000 transitions using 10 leapfrog steps per transition would take 1.07 seconds.
Chain 4: Adjust your expectations accordingly!
Chain 4: 
Chain 4: 
Chain 4: Iteration: 1 / 2000 [0%] (Warmup)
Chain 2: Iteration: 200 / 2000 [10%] (Warmup)
Chain 4: Iteration: 200 / 2000 [10%] (Warmup)
Chain 2: Iteration: 400 / 2000 [20%] (Warmup)
Chain 4: Iteration: 400 / 2000 [20%] (Warmup)
Chain 2: Iteration: 600 / 2000 [30%] (Warmup)
Chain 4: Iteration: 600 / 2000 [30%] (Warmup)
Chain 2: Iteration: 800 / 2000 [40%] (Warmup)
Chain 4: Iteration: 800 / 2000 [40%] (Warmup)
Chain 2: Iteration: 1000 / 2000 [50%] (Warmup)
Chain 2: Iteration: 1001 / 2000 [50%] (Sampling)
Chain 4: Iteration: 1000 / 2000 [50%] (Warmup)
Chain 4: Iteration: 1001 / 2000 [50%] (Sampling)
Chain 2: Iteration: 1200 / 2000 [60%] (Sampling)
Chain 4: Iteration: 1200 / 2000 [60%] (Sampling)
Chain 2: Iteration: 1400 / 2000 [70%] (Sampling)
Chain 4: Iteration: 1400 / 2000 [70%] (Sampling)
Chain 2: Iteration: 1600 / 2000 [80%] (Sampling)
Chain 4: Iteration: 1600 / 2000 [80%] (Sampling)
Chain 2: Iteration: 1800 / 2000 [90%] (Sampling)
Chain 4: Iteration: 1800 / 2000 [90%] (Sampling)
Chain 4: Iteration: 2000 / 2000 [100%] (Sampling)
Chain 4: 
Chain 4: Elapsed Time: 4.21187 seconds (Warm-up)
Chain 4: 3.00345 seconds (Sampling)
Chain 4: 7.21531 seconds (Total)
Chain 4: 
Chain 2: Iteration: 2000 / 2000 [100%] (Sampling)
Chain 2: 
Chain 2: Elapsed Time: 3.86222 seconds (Warm-up)
Chain 2: 3.55775 seconds (Sampling)
Chain 2: 7.41997 seconds (Total)
Chain 2: 
Error in serialize(data, node$con, xdr = FALSE) : ignoring SIGPIPE signal
Calls: <Anonymous> ... doTryCatch -> sendData -> sendData.SOCK0node -> serialize
Execution halted
Error in serialize(data, node$con, xdr = FALSE) : ignoring SIGPIPE signal
Calls: <Anonymous> ... doTryCatch -> sendData -> sendData.SOCK0node -> serialize
Execution halted

```

It looks like only chains 2 and 4 actually ran to completion.

---

<div class="post-metadata">

### Author: ![bgoodri](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bgoodri/32/4451_2.png) [@bgoodri](https://discourse.mc-stan.org/u/bgoodri)
#### Post date: [September 18, 2019, 5:45pm UTC](https://discourse.mc-stan.org/t/complaints-about-slot-mode-rearing-their-head-again/11027/4 "2019-09-18T17:45:34Z")

</div>

Can you post the Stan program?

---

<div class="post-metadata">

### Author: ![jjramsey](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/jjramsey/32/3319_2.png) [@jjramsey](https://discourse.mc-stan.org/u/jjramsey)
#### Post date: [September 18, 2019, 5:48pm UTC](https://discourse.mc-stan.org/t/complaints-about-slot-mode-rearing-their-head-again/11027/5 "2019-09-18T17:48:53Z")

</div>

I’m not sure I can. BTW, [since I’ve started a different and arguably more thorough thread on the topic](https://discourse.mc-stan.org/t/parallel-chains-not-working-different-behavior-in-rstudio-and-r-from-terminal/11038), this thread is pretty much defunct.
