operator.imod - AddressSanitizer: allocation-size-too-big · Issue #136198 · python/cpython · GitHub | Latest TMZ Celebrity News & Gossip | Watch TMZ Live
Skip to content

operator.imod - AddressSanitizer: allocation-size-too-big #136198

Closed as not planned
@gvozdila

Description

@gvozdila

Bug report

Bug description:

import operator

data=str(b"b'o5dkz^YMeLi)x0Q)J'%11111111111111111r")
data2=str(b"b'uuuuuuu\n\n\n\n\n\n\n\n")
ret = operator.imod(data,data2)

When building cpython without sanitizers, there will be a MemoryError.
It looks like the problem is in implicit type conversion. Tested for versions from 3.7 to 3.15

The bug may be related to the bug #136197

Below is the output of ASAN for 3.15 when building with --with-pydebug

    #0 0x55f36db2d395 in __interceptor_realloc (/usr/local/bin/python3.15+0x763395) (BuildId: 510e01f0876b564331a25fd250bbf68603637192)
    #1 0x55f36df6d653 in _PyMem_DebugRawRealloc /root/cpython/Objects/obmalloc.c:3010:20
    #2 0x55f36e0c3285 in resize_compact /root/cpython/Objects/unicodeobject.c:1197:31
    #3 0x55f36e0522ac in _PyUnicodeWriter_PrepareInternal /root/cpython/Objects/unicodeobject.c:13824:25
    #4 0x55f36e0cdd87 in unicode_format_arg_output /root/cpython/Objects/unicodeobject.c:15345:9
    #5 0x55f36e0cdd87 in unicode_format_arg /root/cpython/Objects/unicodeobject.c:15449:15
    #6 0x55f36e0cdd87 in PyUnicode_Format /root/cpython/Objects/unicodeobject.c:15522:17
    #7 0x55f36dd04b2c in binary_op1 /root/cpython/Objects/abstract.c:964:13
    #8 0x55f36dd0640b in binary_iop /root/cpython/Objects/abstract.c:1253:24
    #9 0x55f36dd81ec8 in _PyObject_VectorcallTstate /root/cpython/./Include/internal/pycore_call.h:169:11
    #10 0x55f36e2d7d68 in _PyEval_EvalFrameDefault /root/cpython/Python/generated_cases.c.h:1620:35
    #11 0x55f36e289ad6 in _PyEval_EvalFrame /root/cpython/./Include/internal/pycore_ceval.h:119:16
    #12 0x55f36e289ad6 in _PyEval_Vector /root/cpython/Python/ceval.c:1975:12
    #13 0x55f36e288eab in PyEval_EvalCode /root/cpython/Python/ceval.c:866:21
    #14 0x55f36e5176dd in run_eval_code_obj /root/cpython/Python/pythonrun.c:1365:12
    #15 0x55f36e5176dd in run_mod /root/cpython/Python/pythonrun.c:1436:19
    #16 0x55f36e50bb19 in pyrun_file /root/cpython/Python/pythonrun.c:1293:15
    #17 0x55f36e50bb19 in _PyRun_SimpleFileObject /root/cpython/Python/pythonrun.c:521:13
    #18 0x55f36e50a857 in _PyRun_AnyFileObject /root/cpython/Python/pythonrun.c:81:15
    #19 0x55f36e5bac72 in pymain_run_file_obj /root/cpython/Modules/main.c:410:15
    #20 0x55f36e5bac72 in pymain_run_file /root/cpython/Modules/main.c:429:15
    #21 0x55f36e5bac72 in pymain_run_python /root/cpython/Modules/main.c:691:21
    #22 0x55f36e5bac72 in Py_RunMain /root/cpython/Modules/main.c:772:5
    #23 0x55f36e5bc816 in pymain_main /root/cpython/Modules/main.c:802:12
    #24 0x55f36e5bcaed in Py_BytesMain /root/cpython/Modules/main.c:826:12
    #25 0x7624d19c6249 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16

==177==HINT: if you don't care about these errors you may set allocator_may_return_null=1
SUMMARY: AddressSanitizer: allocation-size-too-big (/usr/local/bin/python3.15+0x763395) (BuildId: 510e01f0876b564331a25fd250bbf68603637192) in __interceptor_realloc
==177==ABORTING

Bug was found using https://github.com/awen-li/PyRTFuzz

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    pendingThe issue will be closed if no feedback is providedtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      TMZ Celebrity News – Breaking Stories, Videos & Gossip

      Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

      Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

      🎥 Watch TMZ Live

      TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.