# Multi-thread Run Problem

**URL:** https://castor-project.discourse.group/t/multi-thread-run-problem/151
**Category:** General Discussions
**Created:** [May 26, 2020, 2:13pm UTC](https://castor-project.discourse.group/t/multi-thread-run-problem/151 "2020-05-26T14:13:21Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Virtuall](https://avatars.discourse-cdn.com/v4/letter/v/ecd19e/32.png) [@Virtuall](https://castor-project.discourse.group/u/Virtuall)
#### Post date: [May 26, 2020, 2:13pm UTC](https://castor-project.discourse.group/t/multi-thread-run-problem/151/1 "2020-05-26T14:13:21Z")

</div>

Dear all,

I am testing CASToR performance on multi-thread running, but it looks like using the multi-thread function is not very stable.  
Before applying multi-thread to recon, every job was good. But recon jobs always dumped with unrecognized problem since I used multi-thread as below:

```auto
***Error in `castor-recon': munmap_chunk(): invalid pointer: 0x0000000002259380***

```

Did anyone ever see this problem before?  
Any answer will be highly appreciated! Thank you!

Best,

---

<div class="post-metadata">

### Author: ![tmerlin](https://yyz2.discourse-cdn.com/free1/user_avatar/castor-project.discourse.group/tmerlin/32/216_2.png) [@tmerlin](https://castor-project.discourse.group/u/tmerlin)
#### Post date: [May 28, 2020, 11:04am UTC](https://castor-project.discourse.group/t/multi-thread-run-problem/151/2 "2020-05-28T11:04:27Z")

</div>

Hi Xinjie,

On which kind of dataset did you get this problem ? Did it occur on every data you tried to reconstruct or just some of them ?

Best,  
Thibaut

Xinjie Cao \<[xinjie.cao@stonybrook.edu](mailto:xinjie.cao@stonybrook.edu)\> a écrit :

---

<div class="post-metadata">

### Author: ![sstute](https://avatars.discourse-cdn.com/v4/letter/s/8c91f0/32.png) [@sstute](https://castor-project.discourse.group/u/sstute)
#### Post date: [May 28, 2020, 11:40am UTC](https://castor-project.discourse.group/t/multi-thread-run-problem/151/3 "2020-05-28T11:40:34Z")

</div>

Hi,

I already got strange results like that when I switch between different compilation. The reason was that sometimes I forgot to clean the compilation. Did you carefully use “make clean” command between each compilation ?

Simon

---

<div class="post-metadata">

### Author: ![Virtuall](https://avatars.discourse-cdn.com/v4/letter/v/ecd19e/32.png) [@Virtuall](https://castor-project.discourse.group/u/Virtuall)
#### Post date: [June 8, 2020, 3:20pm UTC](https://castor-project.discourse.group/t/multi-thread-run-problem/151/4 "2020-06-08T15:20:00Z")

</div>

Hi Thibaut and Simon,

I have compiled two different Castor versions for multi-thread running and single core in separate directories, respectively. The multi-thread is running well now, but single core test had a problem when I move from a lower resolution configuration to a higher one like below,

**First recon try** :

```auto
castor-recon -df Brain_Double_df.Cdh -opti MLEM -it 10:16 -proj joseph -conv gaussian,4.,4.5,3.5::psf -dim 100,100,16 -vox 2.5,2.5,10. -oit -1 -dout Brain_Double

.........
iIterativeAlgorithm::StepAfterSubsetLoop() -> Save image at iteration 10
vAlgorithm::IterateCPU() -> Total time spent | User: 3699 sec | CPU: 3.6990100e+03 sec
sChronoManager::Display() -> Results from the profiling
.........
--> Custom update step 1: 00 hours 00 mins 00 secs 000 ms

```

**Second recon try** :

```auto
castor-recon -df Brain_Double_df.Cdh -opti MLEM -it 2:10 -proj joseph -conv gaussian,4.,4.5,3.5::psf -dim 200,200,16 -vox 1.25,1.25,10. -oit -1 -dout Brain_Double_2

***Break*** segmentation violation
```

---

<div class="post-metadata">

### Author: ![tmerlin](https://yyz2.discourse-cdn.com/free1/user_avatar/castor-project.discourse.group/tmerlin/32/216_2.png) [@tmerlin](https://castor-project.discourse.group/u/tmerlin)
#### Post date: [June 9, 2020, 2:56pm UTC](https://castor-project.discourse.group/t/multi-thread-run-problem/151/5 "2020-06-09T14:56:34Z")

</div>

Hi Xinjie,

Does the crash occur directly after you launch the the reconstruction. Could you run it with -vb 3 to have a bit more feedback ?

There is no reason why you couldn’t change reconstruction parameters between two consecutive reconstructions.

Maybe you could send us/upload your dataset & geometry file so we have a closer look at the problem ?

Best regards,

---

<div class="post-metadata">

### Author: ![Virtuall](https://avatars.discourse-cdn.com/v4/letter/v/ecd19e/32.png) [@Virtuall](https://castor-project.discourse.group/u/Virtuall)
#### Post date: [June 14, 2020, 12:01am UTC](https://castor-project.discourse.group/t/multi-thread-run-problem/151/6 "2020-06-14T00:01:04Z")

</div>

Hi tmerlin,

Here is my dataset, geometry and entire error log. Hope you could find something!  
[![](https://global.discourse-cdn.com/free1/uploads/castor_project/original/1X/bcec071d2daf94f074e0d45f573498975b42d6b0.png)Brain\_Double\_df.Cdf](https://drive.google.com/a/stonybrook.edu/file/d/1wC4X99y4ATwDWGdrh8OoHfPmeA8l_m2G/view?usp=drive_web) ![](https://global.discourse-cdn.com/free1/uploads/castor_project/original/1X/761a97d116c944a5b88340529c3f403786c3a69a.png)  
[![](https://global.discourse-cdn.com/free1/uploads/castor_project/original/1X/bcec071d2daf94f074e0d45f573498975b42d6b0.png)Brain\_Double\_df.Cdh](https://drive.google.com/a/stonybrook.edu/file/d/1CFoCBMTOVrLgbP-chCu4bXVf379jWEQR/view?usp=drive_web) ![](https://global.discourse-cdn.com/free1/uploads/castor_project/original/1X/761a97d116c944a5b88340529c3f403786c3a69a.png)

Best,

[Error-Log](https://castor-project.discourse.group/uploads/short-url/rqkvBHVdoWAfgOEbWBHLfJnfpmd) (43.7 KB)

[Brain\_Double.geom](https://castor-project.discourse.group/uploads/short-url/4hT8drb3JIldzQeJr4FPpdrLFsF.geom) (1.84 KB)

---

<div class="post-metadata">

### Author: ![tmerlin](https://yyz2.discourse-cdn.com/free1/user_avatar/castor-project.discourse.group/tmerlin/32/216_2.png) [@tmerlin](https://castor-project.discourse.group/u/tmerlin)
#### Post date: [June 19, 2020, 6:55pm UTC](https://castor-project.discourse.group/t/multi-thread-run-problem/151/7 "2020-06-19T18:55:24Z")

</div>

Hi Xinjie,

Thanks for your data. I could reproduce your error and it seems it is linked to the Joseph projector. In particular, there is a hard-coded tolerance factor used to compute the planes which are crossed by the lines. Decreasing that factor seems to remove the crash in my tests.

So a quick fix may be to reduce that threshold (you can replace the _src/projector/iProjectorJoseph.cc_ file by the one in attached, then recompile castor).

I am not sure yet whether the crash is limited to that factor. Let me know if it fixes the error for you.

Best,  
Thibaut

[iProjectorJoseph.cc](https://castor-project.discourse.group/uploads/short-url/acBYoNfHXsIvbkVyMAFTx89D6XG.cc) (62.8 KB)

---

<div class="post-metadata">

### Author: ![Virtuall](https://avatars.discourse-cdn.com/v4/letter/v/ecd19e/32.png) [@Virtuall](https://castor-project.discourse.group/u/Virtuall)
#### Post date: [June 24, 2020, 9:39pm UTC](https://castor-project.discourse.group/t/multi-thread-run-problem/151/8 "2020-06-24T21:39:59Z")

</div>

Hi Tmerlin,

It looks like there is no error now, i will let you know if the error appears again. Thanks!

Best,

---

<div class="post-metadata">

### Author: ![h.rashidykanan](https://avatars.discourse-cdn.com/v4/letter/h/a3d4f5/32.png) [@h.rashidykanan](https://castor-project.discourse.group/u/h.rashidykanan)
#### Post date: [January 15, 2024, 12:29pm UTC](https://castor-project.discourse.group/t/multi-thread-run-problem/151/9 "2024-01-15T12:29:28Z")

</div>

Dear Virtuall,

Could you please share again your dataset (Brain\_Double\_df.Cdf and Brain\_Double\_df.Cdh). I want to check out my installed CASToR using Multi-thread.  
Also, Could you please describe how to create this dataset. I assume that, you converted a dataset from a specific scanner (interfile) to CASToR interfile format. Thank you very much in advance.
