[issue41654] Segfault when raising MemoryError

2021-03-16 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 1f0cde678406749524d11e852a16bf243cef5c5f by Miss Islington (bot) 
in branch '3.9':
bpo-41654: Fix compiler warning in MemoryError_dealloc() (GH-22387) (GH-24894)
https://github.com/python/cpython/commit/1f0cde678406749524d11e852a16bf243cef5c5f


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41654] Segfault when raising MemoryError

2021-03-16 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 5.0 -> 6.0
pull_requests: +23656
pull_request: https://github.com/python/cpython/pull/24894

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41654] Segfault when raising MemoryError

2020-09-23 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset bbeb223e9a5e9f9374df384efa386b4068a65c0e by Victor Stinner in 
branch 'master':
bpo-41654: Fix compiler warning in MemoryError_dealloc() (GH-22387)
https://github.com/python/cpython/commit/bbeb223e9a5e9f9374df384efa386b4068a65c0e


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41654] Segfault when raising MemoryError

2020-09-23 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +21429
pull_request: https://github.com/python/cpython/pull/22387

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41654] Segfault when raising MemoryError

2020-09-05 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:


New changeset 6ae61959ec51a6b3dddc8e665ce6a7b8aeb26c04 by Pablo Galindo in 
branch '3.8':
bpo-41654: Explicitly cast PyExc_MemoryError to PyTypeObject to avoid warning 
(GH-22102)
https://github.com/python/cpython/commit/6ae61959ec51a6b3dddc8e665ce6a7b8aeb26c04


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41654] Segfault when raising MemoryError

2020-09-04 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
pull_requests: +21188
pull_request: https://github.com/python/cpython/pull/22102

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41654] Segfault when raising MemoryError

2020-09-04 Thread STINNER Victor

STINNER Victor  added the comment:

"AMD64 Arch Linux Asan 3.8" buildbot logs a compiler warning:
https://buildbot.python.org/all/#builders/580/builds/4

Objects/exceptions.c: In function ‘MemoryError_dealloc’:
Objects/exceptions.c:2298:23: warning: comparison of distinct pointer types 
lacks a cast
 2298 | if (Py_TYPE(self) != PyExc_MemoryError) {
  |   ^~

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41654] Segfault when raising MemoryError

2020-09-02 Thread STINNER Victor


STINNER Victor  added the comment:

Thanks for the fix Pablo! Thanks for the funny bug report Oleg Hoefling! I 
didn't expect that anyone would ever subclass MemoryError.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41654] Segfault when raising MemoryError

2020-09-01 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41654] Segfault when raising MemoryError

2020-09-01 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:


New changeset 77f4000ae0d43a2685face80e7f14d4aba053973 by Pablo Galindo in 
branch '3.8':
[3.8] [3.9] bpo-41654: Fix deallocator of MemoryError to account for subclasses 
(GH-22020) (GH-22046)
https://github.com/python/cpython/commit/77f4000ae0d43a2685face80e7f14d4aba053973


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41654] Segfault when raising MemoryError

2020-09-01 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:


New changeset d14775ddbb067bcfa6eca516d3cbe968a8c1334e by Pablo Galindo in 
branch '3.9':
[3.9] bpo-41654: Fix deallocator of MemoryError to account for subclasses 
(GH-22020) (GH-22045)
https://github.com/python/cpython/commit/d14775ddbb067bcfa6eca516d3cbe968a8c1334e


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41654] Segfault when raising MemoryError

2020-09-01 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
pull_requests: +21142
pull_request: https://github.com/python/cpython/pull/22045

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41654] Segfault when raising MemoryError

2020-09-01 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
pull_requests: +21143
pull_request: https://github.com/python/cpython/pull/22046

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41654] Segfault when raising MemoryError

2020-09-01 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:


New changeset 9b648a95ccb4c3b14f1e87158f5c9f5dbb2f62c0 by Pablo Galindo in 
branch 'master':
bpo-41654: Fix deallocator of MemoryError to account for subclasses (GH-22020)
https://github.com/python/cpython/commit/9b648a95ccb4c3b14f1e87158f5c9f5dbb2f62c0


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41654] Segfault when raising MemoryError

2020-08-30 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

The problem is that the deallocator of MemoryError class is not taking into 
account subclasses for the freelist management, but the allocator (tp_new) is.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41654] Segfault when raising MemoryError

2020-08-30 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
keywords: +patch
nosy: +pablogsal
nosy_count: 4.0 -> 5.0
pull_requests: +21120
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/22020

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41654] Segfault when raising MemoryError

2020-08-30 Thread hai shi


hai shi  added the comment:

Hm, Looks like we need check the double free risk of `Py_DECREF()`.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41654] Segfault when raising MemoryError

2020-08-29 Thread Dong-hee Na


Change by Dong-hee Na :


--
nosy: +corona10

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41654] Segfault when raising MemoryError

2020-08-28 Thread hai shi


Change by hai shi :


--
nosy: +shihai1991

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41654] Segfault when raising MemoryError

2020-08-28 Thread STINNER Victor


STINNER Victor  added the comment:

Aha, interesting bug report. I attached a simplified reproducer.

Output with a Python built in debug mode:
---
Objects/frameobject.c:590: _Py_NegativeRefcount: Assertion failed: object has 
negative ref count

Fatal Python error: _PyObject_AssertFailed: _PyObject_AssertFailed
Python runtime state: initialized

Current thread 0x7efd7a2d0740 (most recent call first):
  File "/home/vstinner/bug.py", line 29 in 
Abandon (core dumped)
---

--
nosy: +vstinner
Added file: https://bugs.python.org/file49431/bug.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41654] Segfault when raising MemoryError

2020-08-28 Thread Oleg Hoefling


Oleg Hoefling  added the comment:

If this is of any help, I've set up an example repository containing the 
snippet: https://github.com/hoefling/bpo-issue-41654

Here are the results of running the snippet in Travis with Python 3.{5-10} and 
Pypy 3.6: https://travis-ci.com/github/hoefling/bpo-issue-41654

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue41654] Segfault when raising MemoryError

2020-08-28 Thread Oleg Hoefling


New submission from Oleg Hoefling :

First of all, I guess this is a somewhat obscure error that is unlikely to 
occur in a usual context, nevertheless IMO worth reporting. We observed this 
when unit-testing custom exception reporting mechanism, raising different 
exceptions in different contexts and then analyzing whether they are processed 
correctly.

This is a somewhat dull example I managed to extract from our tests:


from pathlib import Path
from unittest.mock import patch


class TestException(MemoryError):
pass


class report_ctx:
def __enter__(self):
return self
def __exit__(self, exc_type, exc_value, tb):
report(exc_value)


class raises:
def __init__(self, ex):
self.ex = ex
def __enter__(self):
return self
def __exit__(self, exc_type, exc_value, tb):
return issubclass(exc_type, self.ex)


def report(ex):
pass


def error():
raise MemoryError


modname = Path(__file__).stem

for _ in range(10):
with patch(f"{modname}.report"):
with raises(MemoryError), report_ctx():
raise MemoryError

with raises(TestException):
raise TestException

with raises(MemoryError):
error()

that yields:

Fatal Python error: Segmentation fault

Current thread 0x7fcf0833b740 (most recent call first):
  File 
"/home/oleg.hoefling/projects/private/python-memoryerror-segfault/main.py", 
line 38 in 
  File "", line 228 in _call_with_frames_removed
  File "", line 790 in exec_module
  File "", line 680 in _load_unlocked
  File "", line 986 in _find_and_load_unlocked
  File "", line 1007 in _find_and_load
  File "/usr/lib64/python3.9/unittest/mock.py", line 1236 in _importer
  File "/usr/lib64/python3.9/unittest/mock.py", line 1564 in 
  File "/usr/lib64/python3.9/unittest/mock.py", line 1389 in __enter__
  File 
"/home/oleg.hoefling/projects/private/python-memoryerror-segfault/main.py", 
line 36 in 

--
components: Interpreter Core
messages: 376028
nosy: hoefling
priority: normal
severity: normal
status: open
title: Segfault when raising MemoryError
type: crash
versions: Python 3.10, Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 
3.9

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com