Opened 16 months ago

Last modified 3 weeks ago

#31984 new defect

Can pynac's calculations of special functions cause std::abs to overflow?

Reported by: Dave Morris Owned by:
Priority: major Milestone: sage-9.8
Component: symbolics Keywords: pynac, overflow, absolute value, special functions
Cc: Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: #31585 Stopgaps:

Status badges

Description (last modified by Dave Morris)

The C++ function std::abs can overflow, because the twos-complement binary representation of an integer has a negative number (-2^k, where k + 1 is the number of bits) whose negative requires an additional bit. Some bugs resulting from this are fixed in #31585, but the other occurrences of std::abs in the pynac source code should also be examined, to determine whether they are also buggy.

There is one other occurrence of std::abs in numeric.cpp, but it seems to be safe, because it is taking the absolute value of a floating-point double, not an integer. (Furthermore, this double is known to be less than 10^200.)

I think the remaining occurrences of std::abs are all in the file inifcns_nstdsums.cpp. (In particular, std::abs(scale) appears a few times, where scale is an int variable.) I think this code is computing the values of special functions that are defined by nested sums. (There is mention of "G transformation" and "Hoelder convolution".) It would be great if someone who understands this would take a look at the occurrences of std::abs in the file.

Change History (6)

comment:1 Changed 16 months ago by Dave Morris

Description: modified (diff)

comment:2 Changed 16 months ago by Dave Morris

Description: modified (diff)
Keywords: special functions added
Summary: Pynac should be more careful when it uses std::absCan pynac's calculations of special functions cause std::abs to overflow?

comment:3 Changed 14 months ago by Matthias Köppe

Milestone: sage-9.4sage-9.5

comment:4 Changed 10 months ago by Matthias Köppe

Milestone: sage-9.5sage-9.6

comment:5 Changed 5 months ago by Matthias Köppe

Milestone: sage-9.6sage-9.7

comment:6 Changed 3 weeks ago by Matthias Köppe

Milestone: sage-9.7sage-9.8
Note: See TracTickets for help on using tickets.