Skip to content
This repository was archived by the owner on Jan 31, 2023. It is now read-only.

Latest commit

 

History

History
341 lines (264 loc) · 9.32 KB

20851.md

File metadata and controls

341 lines (264 loc) · 9.32 KB

Issue 20851: Potential infinite loop in src/sage/categories/coercion_methods.pyx

archive/issues_020614.json:

{
    "assignees": [],
    "body": "<div id=\"comment:0\"></div>\n\nThis code from `src/sage/categories/coercion_methods.pyx` looks like a potential infinite loop:\n\n```\n    if have_same_parent_c(self, right) and hasattr(self, \"_add_\"):\n        return self._add_(right)\n    return coercion_model.bin_op(self, right, operator.add)\n```\n\nThe `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__`...\n\nSolution: remove the `hasattr(self, \"_add_\")`.\n\nHopefully the whole module `coercion_methods.pyx` can be removed in #20767 and then the problem will disappear by itself.\n\nCC:  @nthiery\n\nComponent: **categories**\n\nReviewer: **Jeroen Demeyer**\n\n_Issue created by migration from https://trac.sagemath.org/ticket/20851_\n\n",
    "closed_at": "2016-08-30T13:32:25Z",
    "created_at": "2016-06-20T09:09:25Z",
    "labels": [
        "https://github.com/sagemath/sage/labels/bug",
        "https://github.com/sagemath/sage/labels/c%3A%20categories",
        "https://github.com/sagemath/sage/labels/wontfix"
    ],
    "reactions": [],
    "repository": "https://github.com/sagemath/sage",
    "title": "Potential infinite loop in src/sage/categories/coercion_methods.pyx",
    "type": "issue",
    "updated_at": "2016-08-30T13:32:25Z",
    "url": "https://github.com/sagemath/sage/issues/20851",
    "user": "https://github.com/jdemeyer"
}

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.

CC: @nthiery

Component: categories

Reviewer: Jeroen Demeyer

Issue created by migration from https://trac.sagemath.org/ticket/20851


archive/issue_events_290842.json:

{
    "actor": "https://github.com/jdemeyer",
    "created_at": "2016-06-20T09:09:25Z",
    "event": "milestoned",
    "issue": "https://github.com/sagemath/sage/issues/20851",
    "milestone_number": null,
    "milestone_title": "sage-7.3",
    "type": "issue_event",
    "url": "https://github.com/sagemath/sage/issues/20851#event-290842"
}

archive/issue_events_290843.json:

{
    "actor": "https://github.com/jdemeyer",
    "created_at": "2016-06-20T09:09:25Z",
    "event": "labeled",
    "issue": "https://github.com/sagemath/sage/issues/20851",
    "label": "https://github.com/sagemath/sage/labels/c%3A%20categories",
    "label_color": "0000ff",
    "label_name": "c: categories",
    "label_text_color": "ffffff",
    "type": "issue_event",
    "url": "https://github.com/sagemath/sage/issues/20851#event-290843"
}

archive/issue_events_290844.json:

{
    "actor": "https://github.com/jdemeyer",
    "created_at": "2016-06-20T09:09:25Z",
    "event": "labeled",
    "issue": "https://github.com/sagemath/sage/issues/20851",
    "label": "https://github.com/sagemath/sage/labels/p%3A%20major%20/%203",
    "label_color": "ffbb00",
    "label_name": "p: major / 3",
    "label_text_color": "ffffff",
    "type": "issue_event",
    "url": "https://github.com/sagemath/sage/issues/20851#event-290844"
}

archive/issue_events_290845.json:

{
    "actor": "https://github.com/jdemeyer",
    "created_at": "2016-06-20T09:09:25Z",
    "event": "labeled",
    "issue": "https://github.com/sagemath/sage/issues/20851",
    "label": "https://github.com/sagemath/sage/labels/bug",
    "label_color": "d73a4a",
    "label_name": "bug",
    "label_text_color": "ffffff",
    "type": "issue_event",
    "url": "https://github.com/sagemath/sage/issues/20851#event-290845"
}

archive/issue_events_290846.json:

{
    "actor": "https://github.com/jdemeyer",
    "created_at": "2016-08-01T15:13:48Z",
    "event": "labeled",
    "issue": "https://github.com/sagemath/sage/issues/20851",
    "label": "https://github.com/sagemath/sage/labels/needs%20review",
    "label_color": "7fff00",
    "label_name": "needs review",
    "label_text_color": "ffffff",
    "type": "issue_event",
    "url": "https://github.com/sagemath/sage/issues/20851#event-290846"
}

archive/issue_comments_302347.json:

{
    "body": "<div id=\"comment:1\" align=\"right\">comment:1</div>\n\nFixed by #20767.",
    "created_at": "2016-08-01T15:13:48Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20851",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20851#issuecomment-302347",
    "user": "https://github.com/jdemeyer"
}
comment:1

Fixed by #20767.


archive/issue_comments_302348.json:

{
    "body": "Reviewer: **Jeroen Demeyer**",
    "created_at": "2016-08-01T15:13:48Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20851",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20851#issuecomment-302348",
    "user": "https://github.com/jdemeyer"
}

Reviewer: Jeroen Demeyer


archive/issue_events_290847.json:

{
    "actor": "https://github.com/jdemeyer",
    "created_at": "2016-08-01T15:13:48Z",
    "event": "demilestoned",
    "issue": "https://github.com/sagemath/sage/issues/20851",
    "milestone_number": null,
    "milestone_title": "sage-7.3",
    "type": "issue_event",
    "url": "https://github.com/sagemath/sage/issues/20851#event-290847"
}

archive/issue_events_290848.json:

{
    "actor": "https://github.com/jdemeyer",
    "created_at": "2016-08-01T15:13:56Z",
    "event": "unlabeled",
    "issue": "https://github.com/sagemath/sage/issues/20851",
    "label": "https://github.com/sagemath/sage/labels/needs%20review",
    "label_color": "7fff00",
    "label_name": "needs review",
    "label_text_color": "ffffff",
    "type": "issue_event",
    "url": "https://github.com/sagemath/sage/issues/20851#event-290848"
}

archive/issue_events_290849.json:

{
    "actor": "https://github.com/jdemeyer",
    "created_at": "2016-08-01T15:13:56Z",
    "event": "labeled",
    "issue": "https://github.com/sagemath/sage/issues/20851",
    "label": "https://github.com/sagemath/sage/labels/positive%20review",
    "label_color": "dfffc0",
    "label_name": "positive review",
    "label_text_color": "ffffff",
    "type": "issue_event",
    "url": "https://github.com/sagemath/sage/issues/20851#event-290849"
}

archive/issue_comments_302349.json:

{
    "body": "<div id=\"comment:3\" align=\"right\">comment:3</div>\n\nDetermined to be invalid/duplicate/wontfix (closing as \"wontfix\" as a catch-all resolution).",
    "created_at": "2016-08-30T13:32:25Z",
    "formatter": "markdown",
    "issue": "https://github.com/sagemath/sage/issues/20851",
    "type": "issue_comment",
    "url": "https://github.com/sagemath/sage/issues/20851#issuecomment-302349",
    "user": "https://github.com/embray"
}
comment:3

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


archive/issue_events_290850.json:

{
    "actor": "https://github.com/embray",
    "created_at": "2016-08-30T13:32:25Z",
    "event": "unlabeled",
    "issue": "https://github.com/sagemath/sage/issues/20851",
    "label": "https://github.com/sagemath/sage/labels/p%3A%20major%20/%203",
    "label_color": "ffbb00",
    "label_name": "p: major / 3",
    "label_text_color": "ffffff",
    "type": "issue_event",
    "url": "https://github.com/sagemath/sage/issues/20851#event-290850"
}

archive/issue_events_290851.json:

{
    "actor": "https://github.com/embray",
    "created_at": "2016-08-30T13:32:25Z",
    "event": "labeled",
    "issue": "https://github.com/sagemath/sage/issues/20851",
    "label": "https://github.com/sagemath/sage/labels/wontfix",
    "label_color": "c6c6c6",
    "label_name": "wontfix",
    "label_text_color": "ffffff",
    "type": "issue_event",
    "url": "https://github.com/sagemath/sage/issues/20851#event-290851"
}

archive/issue_events_290852.json:

{
    "actor": "https://github.com/embray",
    "created_at": "2016-08-30T13:32:25Z",
    "event": "unlabeled",
    "issue": "https://github.com/sagemath/sage/issues/20851",
    "label": "https://github.com/sagemath/sage/labels/positive%20review",
    "label_color": "dfffc0",
    "label_name": "positive review",
    "label_text_color": "ffffff",
    "type": "issue_event",
    "url": "https://github.com/sagemath/sage/issues/20851#event-290852"
}

archive/issue_events_290853.json:

{
    "actor": "https://github.com/embray",
    "created_at": "2016-08-30T13:32:25Z",
    "event": "closed",
    "issue": "https://github.com/sagemath/sage/issues/20851",
    "type": "issue_event",
    "url": "https://github.com/sagemath/sage/issues/20851#event-290853"
}