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

Crash with co-routine suspension within charm.iwait #198

Open
ZwFink opened this issue Mar 15, 2021 · 0 comments
Open

Crash with co-routine suspension within charm.iwait #198

ZwFink opened this issue Mar 15, 2021 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@ZwFink
Copy link
Contributor

ZwFink commented Mar 15, 2021

Currently, charm.iwait assumes that the body of code that executes for each iteratively-received object does not suspend. If suspension does happen and the next object is received while the code executing within the body of the loop is suspended, the program will crash. This is illustrated in the following block of code:

from charm4py import Chare, Channel, charm, Future, Group, coro

class A(Chare):
    def __init__(self):
        self.partnerProxy = self.thisProxy[not self.thisIndex]
        self.channels = [Channel(self, self.partnerProxy),
                         Channel(self, self.partnerProxy)]

    @coro
    def run(self):
        if self.thisIndex == 0:
            my_ch = self.channels[0]
            self.partner_fut = my_ch.recv()
            my_ch.send(4)
            self.channels[1].send(4)
            self.partner_fut(4)
        else:
            my_fut = Future()
            partner_ch = self.channels[0]
            partner_ch.send(my_fut)
            for ch in charm.iwait(self.channels):
                recvd = ch.recv()

                # this greenlet pauses here and resumes here when
                # the second partner channel is ready to receive
                result = my_fut.get()
                print(recvd, result)

def main(args):
    assert charm.numPes() == 2
    chares = Group(A)
    chares.run()

charm.start(main)

This code will crash with the following (truncated) error message:

    result = my_fut.get()
  File "/home/zane/charm4py/charm4py/threads.py", line 51, in get
    return self.values[0]
  Fatal error on PE 1> TypeError: '_Channel' object is not subscriptable

This error happens because the greenlet that suspends when my_fut.get() is called is awakened when the next channel in self.channels is ready to receive and is yielded by charm.iwait.

@ZwFink ZwFink added the bug Something isn't working label Mar 15, 2021
@ZwFink ZwFink self-assigned this Mar 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant