This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author skrah
Recipients boytsovea, skrah, vstinner, yselivanov
Date 2020-03-03.15:21:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1583248912.41.0.0183239145443.issue39776@roundup.psfhosted.org>
In-reply-to
Content
Also _pydecimal was affected. This is a modified version of Evgeny's
test case:

from _pydecimal import *
from time import sleep
from random import randint
import sys


sys.setswitchinterval(0.0000001)


def usleep(x):
    sleep(x/1000000.0)

class Test:

    def __init__(self, threadno):
        self.threadno = threadno

    def GetCallback(self):
        usleep(randint(0, 9));
        setcontext(Context(Emax=self.threadno))
        usleep(randint(0, 9))
        c = getcontext()
        try:
            if c.Emax != self.threadno:
                raise RuntimeError("GetCallback: another thread changed this thread's context")
        except AttributeError:
            raise RuntimeError("GetCallback: type(c)==%s and c.Emax disappeared" % type(c))
        usleep(randint(0, 9))
        return self.Callback

    def Callback(self):
        c = getcontext()
        try:
            c.Emax = self.threadno
        except AttributeError:
            raise RuntimeError("Callback: type(c)==%s and c.Emax disappeared" % type(c))

def DoTest(threadno):
    return Test(threadno).GetCallback()



It produces one of the exceptions or a segfault. You may have
to build in release mode to get the race.
History
Date User Action Args
2020-03-03 15:21:52skrahsetrecipients: + skrah, vstinner, yselivanov, boytsovea
2020-03-03 15:21:52skrahsetmessageid: <1583248912.41.0.0183239145443.issue39776@roundup.psfhosted.org>
2020-03-03 15:21:52skrahlinkissue39776 messages
2020-03-03 15:21:51skrahcreate