Skip to content

Instantly share code, notes, and snippets.

@smls
Last active October 10, 2016 17:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smls/3c59b3f818d27f3854852afd361e9b95 to your computer and use it in GitHub Desktop.
Save smls/3c59b3f818d27f3854852afd361e9b95 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl6
## Uncommenting the following line makes the bug disappear:
# my $*SCHEDULER = CurrentThreadScheduler;
## Set up a test folder with 26 empty files.
my $folder = "/tmp/concurrent_dir_bug".IO;
$folder.mkdir;
$folder.child("$_$_$_").spurt("") for "a".."z";
## Read the folder from multiple threads, and sanity-check each IO::Path.
## The sanity check should never fail, but at some point it does.
await do for ^20 {
start {
for $folder.dir -> $path {
if $path.absolute ne $path.Str {
die join "\n", <Str absolute gist perl>.map: {
"{.fmt: '%9s'}: {$path."$_"()}"
}
}
}
}
}
Str: /tmp/concurrent_dir_bug/sss
absolute: /tmp/concurrent_dir_bug/vvv
gist: "/tmp/concurrent_dir_bug/vvv".IO
perl: "/tmp/concurrent_dir_bug/vvv".IO(:SPEC(IO::Spec::Unix))
in block <unit> at /home/sam/dev/concurrent_dir_bug.p6 line 13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment