Hello everyone, I’m having a small issue where compiling a Stan model file with STAN_THREADS=true
raises an error if I do not compile it with CXXFLAGS += -fsanitize=undefined
.
This happens in my model as well as with the provided example Bernoulli model file.
Here are the steps to reproduce the bug:
- Clone the
cmdstan
Github repository ; - Add the lines
STAN_THREADS=true
tomake/local
; - Compile the example Bernoulli file;
- Get GCC error.
The error log is fairly large (almost 82k lines) because it seems to be repeating the same block over and over again.
I will not place it here, becaue it includes the symbol “`”, which makes it render poorly.
If you are interested, I have compressed the output (both STDOUT and STDERR) and compressed it into a tarball, which I will share below:
error.tar.gz.txt (572.9 KB)
(NOTE: In order to get it to upload to this forum I had to cheat the system and pretend this is a .txt file… it is actually not! It’s a compressed tarball!).
However, if I add a new step, where I compile the model file with a new line saying CXXFLAGS += -fsanitize=undefined
on the file make/local
, then all goes well.
One additional thing I would like to say is that even though I am compiling with the STAN_THREADS=true
flag, running the sampler with 4 chains and 4 threads in parallel still outputs to different output files.
Could this be a symptom of something else going wrong?
I should say that I stated this as a bug because 1) I don’t see any reason why this should be a requirement and 2) it’s not written in the documentation that catching undefined behavior is a requirement to run the code in parallel.
System
This was tested with cmdstan
versoin 2.30.1.
This is true on two system which I have tested, one of them is my laptop:
- 5.4.225-1-MANJARO #1 SMP PREEMPT Sat Nov 26 00:40:25 UTC 2022 x86_64 GNU/Linux
- gcc (GCC) 11.3.0
And the other is a desktop:
- 6.0.8-arch1-1 #1 SMP PREEMPT_DYNAMIC Thu, 10 Nov 2022 21:14:24 +0000 x86_64 GNU/Linux
- gcc (GCC) 12.2.0