I think there is an issue with the nested AD stuff, i.e. the results from the jacobian function are wrong if no stan::math:var instance was initialized before calling the function.
Attached is a cpp file triggering the error and a comment showing how to fix it from the user side. The respective issue is here:
https://github.com/stan-dev/math/issues/278
... or I have used the set_zero_adjoints_nested() function wrongly... i.e. if that call is replaced with the set_zero_adjoints() function then things work as well.
Best,
Sebastian