Opened 7 years ago

Closed 6 years ago

#20851 closed defect (wontfix)

Potential infinite loop in src/sage/categories/coercion_methods.pyx

Reported by: jdemeyer Owned by:
Priority: major Milestone: sage-duplicate/invalid/wontfix
Component: categories Keywords:
Cc: nthiery Merged in:
Authors: Reviewers: Jeroen Demeyer
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description

This code from src/sage/categories/coercion_methods.pyx looks like a potential infinite loop:

    if have_same_parent_c(self, right) and hasattr(self, "_add_"):
        return self._add_(right)
    return coercion_model.bin_op(self, right, operator.add)

The hasattr(self, "_add_") clause is bad: if there is no _add_, the coercion model will just call __add__, which calls the coercion model, which calls __add__...

Solution: remove the hasattr(self, "_add_").

Hopefully the whole module coercion_methods.pyx can be removed in #20767 and then the problem will disappear by itself.

Change History (3)

comment:1 Changed 7 years ago by jdemeyer

Milestone: sage-7.3sage-duplicate/invalid/wontfix
Reviewers: Jeroen Demeyer
Status: newneeds_review

Fixed by #20767.

comment:2 Changed 7 years ago by jdemeyer

Status: needs_reviewpositive_review

comment:3 Changed 6 years ago by embray

Resolution: wontfix
Status: positive_reviewclosed

Determined to be invalid/duplicate/wontfix (closing as "wontfix" as a catch-all resolution).

Note: See TracTickets for help on using tickets.