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

Many threads results in data corruption #4599

Closed
p6rt opened this issue Sep 27, 2015 · 4 comments
Closed

Many threads results in data corruption #4599

p6rt opened this issue Sep 27, 2015 · 4 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Sep 27, 2015

Migrated from rt.perl.org#126208 (status was 'rejected')

Searchable as RT126208$

@p6rt
Copy link
Author

p6rt commented Sep 27, 2015

From @BenGoldberg1

The code at https://gist.github.com/BenGoldberg1/bc39a9a31eaeb733012a creates many threads for the task of sorting numbers as they are sent to a channel. Roughly twice as many threads are created as there are distinct values.

The output should be a list of random numbers, sorted.

Instead, it produces a error message; changing the number of element to be sorted causes the error message to change. This leads me to conclude that the problem is memory corruption of some sort.

One of the error messages was​:
Attempt to return outside of any Routine␤ in block <unit> at /tmp/4c1CWudfwj​:33
Another error message was​:
Cannot send a message on a closed channel␤ in block <unit> at /tmp/T9gWZ7YfGJ​:33
Another error message was​:
Cannot receive a message on a closed channel␤ in block <unit> at /tmp/rPtHPIxsTw​:33

The funny file names were because I ran the code with camelia, the #perl6 irc bot.

@p6rt
Copy link
Author

p6rt commented Sep 28, 2015

From @moritz

On 09/27/2015 11​:58 PM, Benjamin Goldberg (via RT) wrote​:

# New Ticket Created by Benjamin Goldberg
# Please include the string​: [perl #​126208]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=126208 >

The code at https://gist.github.com/BenGoldberg1/bc39a9a31eaeb733012a creates many threads for the task of sorting numbers as they are sent to a channel. Roughly twice as many threads are created as there are distinct values.

The output should be a list of random numbers, sorted.

Instead, it produces a error message; changing the number of element to be sorted causes the error message to change. This leads me to conclude that the problem is memory corruption of some sort.

One of the error messages was​:
Attempt to return outside of any Routine␤ in block <unit> at /tmp/4c1CWudfwj​:33

I think this error message is correct

#!/usr/bin/env perl6
use v6;

sub sort-promise ($c) {
  start {
  my @​same;
  earliest $c {
  more $c { push @​same, $c.receive }
  done $c { return }
  }

You try to return from a routine through a start { } boundary -- I don't
think that's allowed.

Another error message was​:
Cannot send a message on a closed channel␤ in block <unit> at /tmp/T9gWZ7YfGJ​:33

Can be correct as well. I don't think you wait with the .close until all
the other tasks are done.

Another error message was​:
Cannot receive a message on a closed channel␤ in block <unit> at /tmp/rPtHPIxsTw​:33

Same here.

@p6rt
Copy link
Author

p6rt commented Sep 28, 2015

The RT System itself - Status changed from 'new' to 'open'

@p6rt p6rt closed this as completed Sep 28, 2015
@p6rt
Copy link
Author

p6rt commented Sep 28, 2015

@moritz - Status changed from 'open' to 'rejected'

@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant