Closed rom1v closed 9 months ago
It seems the problem exists in the example algorithm from the RFC 6330 section 4.3:
o N_max = floor(T/(SS*Al)) // if T < SS*Al, then N_max = 0
o for all n=1, ..., N_max // KL(n) is not defined for n=0
* KL(n) is the maximum K' value in Table 2 in Section 5.6 such
that
K' <= WS/(Al*(ceil(T/(Al*n))))
o Z = ceil(Kt/KL(N_max)) // calls KL(0) if T < SS*Al
In practice, this is not a real problem, since it does not make sense to take such a small value of T, but it should not cause a division by 0.
If I pass a number lower than 64 to
Encoder::with_defaults()
, then a division by 0 occurs:A variable
n_max
is assigned from the integer division32 / (8 * 8)
, which is 0:https://github.com/cberner/raptorq/blob/92cd14ab12f6907226add0f4ea6bcfc9840c9985/src/base.rs#L212
This
n_max
is passed as parameter to a closure here:https://github.com/cberner/raptorq/blob/92cd14ab12f6907226add0f4ea6bcfc9840c9985/src/base.rs#L224
The closure calls
int_div_ceil(symbol_size as u64, alignment as u64 * n as u64)
, so the second parameter is 0:https://github.com/cberner/raptorq/blob/92cd14ab12f6907226add0f4ea6bcfc9840c9985/src/base.rs#L216
I let you decide what to do to fix the problem (maybe force
n_max
to be at least 1?).From a separate project with basically the same code as the
example.rs
but withEncoder::with_defaults(&data, an_integer_lower_than_64)
, I get anunreachable code
error instead:I don't know why I can't reproduce this error by running the example from the raptorq project directly.