Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix circular module loading detection and error messaging
  • Loading branch information
niner committed Nov 25, 2015
1 parent 7155a27 commit 5344dfd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 2 additions & 0 deletions src/core/CompUnit/PrecompilationRepository.pm
Expand Up @@ -62,12 +62,14 @@ class CompUnit::PrecompilationRepository::Default does CompUnit::PrecompilationR
?? '--ll-exception'
!! Empty;
%*ENV<RAKUDO_PRECOMP_WITH> = $*REPO.repo-chain>>.path-spec.join(',');
%*ENV<RAKUDO_PRECOMP_LOADING> = to-json @*MODULES;

RAKUDO_MODULE_DEBUG("Precomping with %*ENV<RAKUDO_PRECOMP_WITH>")
if $*RAKUDO_MODULE_DEBUG;

my $proc = run($*EXECUTABLE, $lle, "--target={$*VM.precomp-target}", "--output=$io", $path, :out);
%*ENV<RAKUDO_PRECOMP_WITH>:delete;
%*ENV<RAKUDO_PRECOMP_LOADING>:delete;

my @result = $proc.out.lines;
if not $proc.out.close or $proc.status { # something wrong
Expand Down
1 change: 1 addition & 0 deletions src/core/CompUnit/Repository/Installation.pm
Expand Up @@ -106,6 +106,7 @@ sub MAIN(:$name is copy, :$auth, :$ver, *@, *%) {

method install(Distribution $dist, %sources, %scripts?, %resources?) {
$!lock.protect( {
my @*MODULES;
my $path = self.writeable-path or die "No writeable path found";
my $lock //= $.prefix.child('repo.lock').open(:create, :w);
$lock.lock(2);
Expand Down
17 changes: 7 additions & 10 deletions src/core/CompUnitRepo.pm
Expand Up @@ -66,21 +66,18 @@ RAKUDO_MODULE_DEBUG("Looking in $spec for $name")
RAKUDO_MODULE_DEBUG("going to load $module_name: %opts.perl()") if $*RAKUDO_MODULE_DEBUG;
$lock.protect( {
my @MODULES = nqp::clone(@*MODULES // ());
for @MODULES -> $m {
if $m<module> && $m<module> eq $module_name {
nqp::die("Circular module loading detected involving module '$module_name'");
}
}

{
my @*MODULES := @MODULES;
if +@*MODULES == 0 {
@*MODULES[0] = { line => $line, filename => nqp::getlexdyn('$?FILES') };
if +@*MODULES == 0 and %*ENV<RAKUDO_PRECOMP_LOADING> -> $loading {
@*MODULES := from-json $loading;
}
else {
@*MODULES[*-1] = { line => $line };
for @*MODULES.list -> $m {
if $m eq $module_name {
nqp::die("Circular module loading detected involving module '$module_name'");
}
}
@*MODULES.push: { module => $module_name, filename => ~($file // '') };
@*MODULES.push: $module_name;

if %opts<from> {
# See if we need to load it from elsewhere.
Expand Down

0 comments on commit 5344dfd

Please sign in to comment.