Re: Infinite loop in CircularBuffer constructor (corner case)
Created https://github.com/DataTorrent/Netlet/issues/60 and pull request https://github.com/DataTorrent/Netlet/pull/59 Ram On Sun, Jan 29, 2017 at 6:42 PM, Vlad Rozovwrote: > Netlet is not an Apache project. Please open issue on github > https://github.com/DataTorrent/netlet/issues. > > Thank you, > > Vlad > > On 12/22/16 18:02, Munagala Ramanath wrote: > >> Actually, this will happen whenever the parameter n satisfies: 2**30 < n >> <= >> Integer.MAX_VALUE >> >> Ram >> >> On Thu, Dec 22, 2016 at 5:34 PM, Munagala Ramanath >> wrote: >> >> In Netlet CircularBuffer constructor, we have an infinite loop if the >>> first parameter (*n*) >>> is *Integer.MAX_VALUE* because the loop counter left-shifts 1 till it >>> drops into the sign >>> bit at which point the value is negative and fails the loop exit test. >>> The >>> next left shift >>> yields 0 which, of course, stays that way forever; here is the fragment: >>> >>> *int i = 1;* >>> *while (i < n) {* >>> * i <<= 1;* >>> *}* >>> >>> Ram >>> >>> >
Re: Infinite loop in CircularBuffer constructor (corner case)
Netlet is not an Apache project. Please open issue on github https://github.com/DataTorrent/netlet/issues. Thank you, Vlad On 12/22/16 18:02, Munagala Ramanath wrote: Actually, this will happen whenever the parameter n satisfies: 2**30 < n <= Integer.MAX_VALUE Ram On Thu, Dec 22, 2016 at 5:34 PM, Munagala Ramanathwrote: In Netlet CircularBuffer constructor, we have an infinite loop if the first parameter (*n*) is *Integer.MAX_VALUE* because the loop counter left-shifts 1 till it drops into the sign bit at which point the value is negative and fails the loop exit test. The next left shift yields 0 which, of course, stays that way forever; here is the fragment: *int i = 1;* *while (i < n) {* * i <<= 1;* *}* Ram
Re: Infinite loop in CircularBuffer constructor (corner case)
Actually, this will happen whenever the parameter n satisfies: 2**30 < n <= Integer.MAX_VALUE Ram On Thu, Dec 22, 2016 at 5:34 PM, Munagala Ramanathwrote: > In Netlet CircularBuffer constructor, we have an infinite loop if the > first parameter (*n*) > is *Integer.MAX_VALUE* because the loop counter left-shifts 1 till it > drops into the sign > bit at which point the value is negative and fails the loop exit test. The > next left shift > yields 0 which, of course, stays that way forever; here is the fragment: > > *int i = 1;* > *while (i < n) {* > * i <<= 1;* > *}* > > Ram >
Infinite loop in CircularBuffer constructor (corner case)
In Netlet CircularBuffer constructor, we have an infinite loop if the first parameter (*n*) is *Integer.MAX_VALUE* because the loop counter left-shifts 1 till it drops into the sign bit at which point the value is negative and fails the loop exit test. The next left shift yields 0 which, of course, stays that way forever; here is the fragment: *int i = 1;* *while (i < n) {* * i <<= 1;* *}* Ram