matrix column indexing bounds check bug in Stan 2.6

58 views
Skip to first unread message

Bob Carpenter

unread,
Mar 5, 2015, 4:59:15 PM3/5/15
to stan-...@googlegroups.com
There's a pretty serious bug in our bounds checking for
matrices that was introduced in Stan 2.6.

If you have a matrix with more cols than rows, and try
to index past the number of columns, Stan will throw an error.
For example, this will throw an error but shouldn't:

matrix[2,3] z;
for (m in 1:2)
for (n in 1:3)
y <- y + z[m,n];

It will throw as soon as n > 2.

If you don't have matrices with more columns than rows that
you are indexing directly, you won't tickle this bug with 2.6.

We have it fixed on a branch (currently undergoing full
integration testing) and will be doing a 2.6.1 release ASAP.

The good news is we're also removing the long long type (we
figured out how to ifdef it so it would still work with 64-bit
Windows's crazy decision to make long types 32 bits). This was
the last obstacle to getting RStan onto CRAN, so expect to
see RStan on CRAN soon after the 2.6.1 release.

Sorry for any inconvenience this might cause.

- Bob

P.S. Many thanks to Aki Vehtari for finding the bug and providing
a simple A-B test case that let us diagnose the problem
quickly.

Aki Vehtari

unread,
Mar 6, 2015, 3:29:32 AM3/6/15
to stan-...@googlegroups.com
Great that you were able to fix the bug quickly! Then my LOO examples will work with 2.6.1, too :)

Aki

Bob Carpenter

unread,
Mar 6, 2015, 4:05:15 AM3/6/15
to stan-...@googlegroups.com
Sorry about breaking things in 2.6.0. I'm really surprised
nobody reported this --- the saving bit is that in stats,
most matrices are either square or have more rows than columns,
which wouldn't have broken anything.

The next official release will be 2.6.2, because we tagged but
didn't release a still-buggy 2.6.1 version. Daniel thinks he'll
be able to get everything together for it for releasing next week.

- Bob
> --
> 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.

Reply all
Reply to author
Forward
0 new messages