It is a bug of stan. I am attaching the standalone stan code and a sample data.
$ lldb ./test optimize data file=seg.Rdump
(lldb) target create "./test"
Current executable set to './test' (x86_64).
(lldb) settings set -- target.run-args "optimize" "data" "file=seg.Rdump"
(lldb) run
Process 7943 launched: './test' (x86_64)
method = optimize
optimize
algorithm = lbfgs (Default)
lbfgs
init_alpha = 0.001 (Default)
tol_obj = 9.9999999999999998e-13 (Default)
tol_rel_obj = 10000 (Default)
tol_grad = 1e-08 (Default)
tol_rel_grad = 10000000 (Default)
tol_param = 1e-08 (Default)
history_size = 5 (Default)
iter = 2000 (Default)
save_iterations = 0 (Default)
id = 0 (Default)
data
file = seg.Rdump
init = 2 (Default)
random
seed =
3252267060
output
file = output.csv (Default)
diagnostic_file = (Default)
refresh = 100 (Default)
Process 7943 stopped
* thread #1: tid = 0x651bc, 0x00000001000468dc test`double stan::model::log_prob_grad<true, false, test_model_namespace::test_model>(test_model_namespace::test_model const&, std::__1::vector<double, std::__1::allocator<double> >&, std::__1::vector<int, std::__1::allocator<int> >&, std::__1::vector<double, std::__1::allocator<double> >&, std::__1::basic_ostream<char, std::__1::char_traits<char> >*) + 636, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
frame #0: 0x00000001000468dc test`double stan::model::log_prob_grad<true, false, test_model_namespace::test_model>(test_model_namespace::test_model const&, std::__1::vector<double, std::__1::allocator<double> >&, std::__1::vector<int, std::__1::allocator<int> >&, std::__1::vector<double, std::__1::allocator<double> >&, std::__1::basic_ostream<char, std::__1::char_traits<char> >*) + 636
test`double stan::model::log_prob_grad<true, false, test_model_namespace::test_model>(test_model_namespace::test_model const&, std::__1::vector<double, std::__1::allocator<double> >&, std::__1::vector<int, std::__1::allocator<int> >&, std::__1::vector<double, std::__1::allocator<double> >&, std::__1::basic_ostream<char, std::__1::char_traits<char> >*) + 636:
-> 0x1000468dc: callq *0x8(%rax)
0x1000468df: movq (%r14), %rcx
0x1000468e2: movq 0x8(%r14), %rax
0x1000468e6: incq %rbx
(lldb) bt
* thread #1: tid = 0x651bc, 0x00000001000468dc test`double stan::model::log_prob_grad<true, false, test_model_namespace::test_model>(test_model_namespace::test_model const&, std::__1::vector<double, std::__1::allocator<double> >&, std::__1::vector<int, std::__1::allocator<int> >&, std::__1::vector<double, std::__1::allocator<double> >&, std::__1::basic_ostream<char, std::__1::char_traits<char> >*) + 636, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
* frame #0: 0x00000001000468dc test`double stan::model::log_prob_grad<true, false, test_model_namespace::test_model>(test_model_namespace::test_model const&, std::__1::vector<double, std::__1::allocator<double> >&, std::__1::vector<int, std::__1::allocator<int> >&, std::__1::vector<double, std::__1::allocator<double> >&, std::__1::basic_ostream<char, std::__1::char_traits<char> >*) + 636
frame #1: 0x000000010004634d test`stan::optimization::ModelAdaptor<test_model_namespace::test_model>::operator()(Eigen::Matrix<double, -1, 1, 0, -1, 1> const&, double&, Eigen::Matrix<double, -1, 1, 0, -1, 1>&) + 253
frame #2: 0x0000000100048c8b test`stan::optimization::BFGSMinimizer<stan::optimization::ModelAdaptor<test_model_namespace::test_model>, stan::optimization::LBFGSUpdate<double, -1>, double, -1>::initialize(Eigen::Matrix<double, -1, 1, 0, -1, 1> const&) + 347
frame #3: 0x0000000100048aee test`stan::optimization::BFGSLineSearch<test_model_namespace::test_model, stan::optimization::LBFGSUpdate<double, -1>, double, -1>::initialize(std::__1::vector<double, std::__1::allocator<double> > const&) + 270
frame #4: 0x00000001000486fe test`stan::optimization::BFGSLineSearch<test_model_namespace::test_model, stan::optimization::LBFGSUpdate<double, -1>, double, -1>::BFGSLineSearch(test_model_namespace::test_model&, std::__1::vector<double, std::__1::allocator<double> > const&, std::__1::vector<int, std::__1::allocator<int> > const&, std::__1::basic_ostream<char, std::__1::char_traits<char> >*) + 158
frame #5: 0x00000001000088cc test`int stan::common::command<test_model_namespace::test_model>(int, char const**) + 11612
frame #6: 0x0000000100003e92 test`main + 18
frame #7: 0x00007fff849445c9 libdyld.dylib`start + 1
frame #8: 0x00007fff849445c9 libdyld.dylib`start + 1
(lldb)
Jiqiang
> --
> You received this message because you are subscribed to the Google Groups "Stan users mailing list" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
stan-users+...@googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.