Skip to content

nogil segmentation fault on ordered dict operations #125996

Open
@luisggpina

Description

@luisggpina

Crash report

What happened?

Hi,

We're a research group focused on testing concurrent runtimes. Our work-in-progress prototype found a segmentation fault on the current nogil build when using concurrent operations on the same ordered dict. The program below shows the crash.

from threading import Barrier, Thread
import sys
from collections import OrderedDict

d = OrderedDict({"k1": "v1", "k2": "v2", 1: 2})

def t1(b1):
    b1.wait()
    try:
        d.move_to_end("k1")
    except:
        None
def t2(b1):
    b1.wait()
    d.clear()
    

def test(): 
    
    global d
    barrier = Barrier(2) 
    threads = [ Thread(target= t1, args=(barrier,)) , Thread(target= t2, args=(barrier,)) ]
    
    d = OrderedDict({"k1": "v1", "k2": "v2", 1: 2})

    for t in threads:
        t.start()
    for t in threads:
        t.join()

print("Test begin...")

for i in range(0,1000):
    test()

print("Test Done")

We ran this on our build from source configured with ./configure --disable-gil.

Here's some details about the OS, compiler, binutils: Linux version 5.15.0-124-generic (buildd@lcy02-amd64-118) (gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #134-Ubuntu SMP Fri Sep 27 20:20:17 UTC 2024

@flypoodles and @overlorde are part of the team, adding them so they get notified about further discussion.

We're happy to provide more details about the crash.

CPython versions tested on:

3.13, 3.14, CPython main branch

Operating systems tested on:

Linux

Output from running 'python -VV' on the command line:

Python 3.14.0a1+ experimental free-threading build (heads/main:c5b99f5c2c5, Oct 25 2024, 17:31:30) [GCC 11.4.0]

Linked PRs

Metadata

Metadata

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy