Segfault, C++, autodiff

Quick question… I’m segfaulting somewhere, and I’d like this to work. I have a debugger open right now, but it’s not very helpful.

What can I use/do to see exactly what my issue is? Use Valgrind or some memory analysis tool?

Not sure what other information I can give, but here’s what I’m looking at:

Program received signal SIGSEGV, Segmentation fault.
0x00000000004138d9 in operator+ (b=..., a=...) at ./stan/math/rev/core/operator_addition.hpp:54
54        return make_callback_vari(a.vi_->val_ + b.vi_->val_,

Was this the result of running a Stan model or from some hand-coded C++? If it was from a Stan model, would you be able to share the code?

My guess as to what’s happening is one side or the other of the addition has a null pointer as their vi_ member. You may already be doing this, but compiling with debug symbols (-Og -g3) may help explore the backtrace further

This is helpful. Hand-coded C++, no stan code. There’s no stan model to share…

Thank you!

1 Like