New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
np.pad(..., mode="reflect") on an empty array goes into an infinite loop #9560
Comments
|
Can you give an example of a |
|
like this : In [2]: mm = np.ndarray(0) In [3]: mm In [4]: np.pad(mm,100,'reflect') |
|
And I print the parameters to a text file, so that we can easily confirm it. This is the part of the text file: iter_b: -3 iter_b: -9 iter_b: -27 iter_b: -81 iter_b: -243 In the text file, the safe_0 is the initial value of the safe_pad, and others are easily to know which parameters they represent. |
|
When given a zero-dimensional array (also known as a scalar), pad seems to return the input unchanged: The docs say that pad adds padding along each axis, and a scalar has zero axes, so returning the input unchanged looks correct to me. Maybe this is a bug in how librosa is expecting |
|
The bug is happened when give a empty list or numpy.ndarray ll=[] |
|
Whoops, I misread, sorry. Yeah, I can confirm that I think what's going on is that if you have, say, an array with 10 elements and you ask for 20 elements of reflected padding... it can't actually do that directly, because there are only 10 elements there to reflect. (And in fact you really only have 9, because the reflection of If you have an empty array, though, then... what does reflected padding even mean? There aren't any elements to reflect. I think the only thing to do in this case is to detect it and raise an error. |
|
Yeah, I read the comment and learn more deeply from your explaination! When I use librosa.load function to read an audio file, it return an empty array in some cases, and this will cause the python process stuck but don't tell me the wrong place. And it takes some hours to find it. Thank you! |
Interesting. If it's a bug in librosa, I think it's going to be down to not checking for non-empty input, rather than violating expectations of I'll tack the array shape check onto our audio validation issue librosa/librosa#612 , which should result in early failure for these cases. |
|
Yes, I find this bug when I tested librosa library last week. When I use librosa.load function to load an special constructed audio file, it returns a empty array. And in the stft function, it will pass the check of the util.valid_audio function and return true. Thanks for your reply! @bmcfee |
|
hey there! do you plan to cut a point release with this fix? it has currently assigned a CVE (https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-12852) so it seems like the right way to go with an upstream release instead of just patching it for debian |
|
@sandrotosi: AFAIK "assigned a CVE" just means "someone filed for a CVE number", it isn't a judgment of severity. Does Debian consider this high priority? It's theoretically possible that there's some piece of network-facing code out there that calls |
|
i know i know, but still someone took the time to request a CVE and open a request to get this fixed in Debian - nothing urgent, i think the risk is rather low, still i would consider to include the fix in any upcoming release |
|
Because I was pointed at this today, let me add a comment on the status here. Debian classifier this as In general, I'd say we consider CVEs like this invalid. If you can call |
When I test librosa library for speech recognition, I found a bug in librosa.stft and librosa.pad_center function which used numpy.pad function.
In my test, it will stick into infinite loop ,once accepted a empty list or ndarray, the numpy.pad function will stick into infinite loop.
Although the comment says that the function need a rank 1 array, but I think it still need to check the input array to avoid the above problem.
Look forward to your reply!
The text was updated successfully, but these errors were encountered: