Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

segfault caused by nested calls to map() #68794

Closed
dlukes mannequin opened this issue Jul 10, 2015 · 4 comments
Closed

segfault caused by nested calls to map() #68794

dlukes mannequin opened this issue Jul 10, 2015 · 4 comments
Labels
type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@dlukes
Copy link
Mannequin

dlukes mannequin commented Jul 10, 2015

BPO 24606
Nosy @serhiy-storchaka, @dlukes
Superseder
  • bpo-14010: deeply nested itertools objects segfault
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2015-07-11.04:50:56.824>
    created_at = <Date 2015-07-10.15:50:22.182>
    labels = ['type-crash']
    title = 'segfault caused by nested calls to map()'
    updated_at = <Date 2015-07-11.04:50:56.794>
    user = 'https://github.com/dlukes'

    bugs.python.org fields:

    activity = <Date 2015-07-11.04:50:56.794>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2015-07-11.04:50:56.824>
    closer = 'serhiy.storchaka'
    components = []
    creation = <Date 2015-07-10.15:50:22.182>
    creator = 'dlukes'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 24606
    keywords = []
    message_count = 4.0
    messages = ['246567', '246588', '246591', '246593']
    nosy_count = 3.0
    nosy_names = ['BreamoreBoy', 'serhiy.storchaka', 'dlukes']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '14010'
    type = 'crash'
    url = 'https://bugs.python.org/issue24606'
    versions = ['Python 3.4']

    @dlukes
    Copy link
    Mannequin Author

    dlukes mannequin commented Jul 10, 2015

    The following program makes Python 3.4.3 crash with a segmentation fault:

    #!/usr/bin/env python3
    
    import operator
    
    N = 500000
    l = [0]
    
    for i in range(N):
        l = map(operator.add, l, [1])
    
    print(list(l))
    

    I suppose the problem is that there are too many nested lazy calls to map, which cause a segfault when evaluated. I've played with N and surprisingly, the threshold to cause the crash varied slightly (between 130900 and 131000 on my machine).

    I know that a list-comprehension, which is evaluated straight away, would be much more idiomatic for repeated element-wise addition (or numpy arrays for that matter, if available). I'm **not advocating this piece of code**, just wondering whether there couldn't be a more informative way to make Python bail out instead of the segfault? (In my real application, it took me a while to figure where the problem was without a stack trace.)

    @dlukes dlukes mannequin added the type-crash A hard crash of the interpreter, possibly with a core dump label Jul 10, 2015
    @BreamoreBoy
    Copy link
    Mannequin

    BreamoreBoy mannequin commented Jul 11, 2015

    FTR I can reproduce this on Windows 8.1 with 3.4.3 and 3.3.5 but not 2.7.10 or 2.6.6.

    @ned-deily
    Copy link
    Member

    Process 51270 launched: './python' (x86_64)
    Process 51270 stopped

    • thread Support "bpo-" in Misc/NEWS #1: tid = 0x5c8677, 0x00000001000c1af8 python_PyObject_Alloc(use_calloc=0, ctx=<unavailable>, nelem=<unavailable>, elsize=<unavailable>) + 24 at obmalloc.c:1170, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=2, address=0x7fff5ebffff8) frame #0: 0x00000001000c1af8 python_PyObject_Alloc(use_calloc=0, ctx=, nelem=, elsize=) + 24 at obmalloc.c:1170
      1167
      1168 static void *
      1169 _PyObject_Alloc(int use_calloc, void *ctx, size_t nelem, size_t elsize)
      -> 1170 {
      1171 size_t nbytes;
      1172 block *bp;
      1173 poolp pool;
      (lldb) bt
    • thread Support "bpo-" in Misc/NEWS #1: tid = 0x5c8677, 0x00000001000c1af8 python`_PyObject_Alloc(use_calloc=0, ctx=, nelem=, elsize=) + 24 at obmalloc.c:1170, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=2, address=0x7fff5ebffff8)

    @serhiy-storchaka
    Copy link
    Member

    This looks as a duplicate of bpo-14010.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    type-crash A hard crash of the interpreter, possibly with a core dump
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants