MPMCQueue - FPE to invalid_argument for 0 capacity
authorDaniel Pittman <dpittman@fb.com>
Tue, 31 Mar 2015 20:33:48 +0000 (13:33 -0700)
committerafrind <afrind@fb.com>
Thu, 2 Apr 2015 19:00:58 +0000 (12:00 -0700)
commit13dda79bc84d292539fbcb8608d2784838a40ffc
treef2c6ab9d38821de58379d60395cb7fda14d8c0f0
parent43989f9df882e5f2fb8c33800c29c596f2e61ce6
MPMCQueue - FPE to invalid_argument for 0 capacity

Summary:
If an MPMCQueue was initialized with an explicit zero capacity, it would
try to compute stride for zero and trigger SIGFPE which pretty fatally
killed the process -- but in a way that required gdb to figure out the
root cause.

This replaces that with a std::invalid_argument exception, which
includes a description of the problem and should make fixing this user
error much faster.

Test Plan:
GTEST unit test added to verify behaviour; if this didn't work it would
SIGFPE and abort the test script, which is probably a good indicator
that something went wrong. :)

fbconfig -r folly && fbmake runtests

Reviewed By: ngbronson@fb.com

Subscribers: chalfant, folly-diffs@, yfeldblum, rkomorn

FB internal diff: D1930978

Signature: t1:1930978:1427740315:cc06a8b9f3c314b956ae41f813b2f904d3e979c9
folly/MPMCQueue.h
folly/test/MPMCQueueTest.cpp