diff options
author | Tom Rondeau <tom@trondeau.com> | 2016-01-27 11:21:25 -0500 |
---|---|---|
committer | Tom Rondeau <tom@trondeau.com> | 2016-01-27 11:21:25 -0500 |
commit | 9606e1f92541f4495973bc78d4cba0f053949042 (patch) | |
tree | 1baa6ed1f415a80b2bfc4ff5b7ed62cf755096b7 /gnuradio-runtime/lib/block_executor.cc | |
parent | 4ce1d4991f41173d6e2e6469f6b61e205b7172a5 (diff) |
runtime: addresses issue 768.
Because of the data types in use here, d_ninput_items_required can
overflow and become negative, which then causes bad addressing of the
input buffer in a block's work function. Even if we were using
unsigned types, we might still have situations of overflow; it
wouldn't crash in this case but cause wrong addressing, anyways.
We might be able to catch and handle this situation better. This fix
tests for the condition and shuts down the flowgraph with an error
message. Basically, parameters that cause this effect are well out of
bounds of what we want to handle, anyways.
Diffstat (limited to 'gnuradio-runtime/lib/block_executor.cc')
-rw-r--r-- | gnuradio-runtime/lib/block_executor.cc | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/gnuradio-runtime/lib/block_executor.cc b/gnuradio-runtime/lib/block_executor.cc index ded1324fa3..ef2e4948bd 100644 --- a/gnuradio-runtime/lib/block_executor.cc +++ b/gnuradio-runtime/lib/block_executor.cc @@ -370,12 +370,25 @@ namespace gr { // ask the block how much input they need to produce noutput_items m->forecast (noutput_items, d_ninput_items_required); - // See if we've got sufficient input available + // See if we've got sufficient input available and make sure we + // didn't overflow on the input. int i; - for(i = 0; i < d->ninputs (); i++) + for(i = 0; i < d->ninputs (); i++) { if(d_ninput_items_required[i] > d_ninput_items[i]) // not enough break; + if(d_ninput_items_required[i] < 0) { + std::cerr << "\nsched: <block " << m->name() + << " (" << m->unique_id() << ")>" + << " thinks its ninput_items required is " + << d_ninput_items_required[i] + << " and cannot be negative.\n" + << "Some parameterization is wrong. " + << "Too large a decimation value?\n\n"; + goto were_done; + } + } + if(i < d->ninputs()) { // not enough input on input[i] // if we can, try reducing the size of our output request if(noutput_items > m->output_multiple()) { |