Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
Bug report
Bug description:
https://github.com/python/cpython/blob/main/Objects/complexobject.c#L150_Py_c_pow() contains:
at=atan2(a.imag,a.real);phase=at*b.real;if (b.imag!=0.0) {len /=exp(at*b.imag);
An oss-fuzz pycompiler fuzzer identified a problem compiling the code " 9J**33J**3" within the optimizer folding the constant by doing the math in place. We haven't been able to reproduce this ourselves - but code inspection reveals a potential problem:
Cexp(x) can return 0 in a couple of cases. Which would lead to the /= executing an undefined division by zero operation.
I believe the correct_Py_c_pow() code should look something like:
if (b.imag!=0.0) {doubletmp_exp=exp(at*b.imag);if (exp==0.0||errno==ERANGE) {// Detected as OverflowError by our caller.r.real=Py_HUGE_VAL;r.imag=Py_HUGE_VAL;returnr; }len /=tmp_exp;
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux