Skip to content

Commit

Permalink
New workaround for dealing with PackageInfo records in HPC-GAP.
Browse files Browse the repository at this point in the history
In order to make PackageInfo records accessible from other threads,
they need to be immutable, readonly, or atomic. Previously, they
were made immutable, but that broke packages that altered them after
initialization. The new workaround makes the package record itself
atomic and its contents immutable.

See issue #2568 for further discussion.
  • Loading branch information
rbehrends committed Apr 21, 2020
1 parent 9cf11a9 commit 758a08c
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions lib/package.gi
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,15 @@ BindGlobal( "AddPackageInfos", function( files, pkgdir, ignore )
record.PackageDoc:= [ record.PackageDoc ];
fi;
if IsHPCGAP then
# FIXME: we make the package info record immutable, to
# allow access from multiple threads; but that in turn
# can break packages, which rely on their package info
# record being readable (see issue #2568)
MakeImmutable(record);
# FIXME: we make the package info record atomic and its
# entries immutable in order to allow for access from
# multiple threads. This is an iteration on a previous
# workaround related to issue #2568, where packages rely on
# being able to update packag info later. It can still break
# packages that either write thread-local information into
# this record that then get accessed from other threads or
# by concurrent access from multiple threads.
record := AtomicRecord(MakeReadOnlyObj(record));
fi;
Add( GAPInfo.PackagesInfo, record );
fi;
Expand Down Expand Up @@ -343,11 +347,11 @@ InstallGlobalFunction( InitializePackagesInfoRecords, function( arg )
record.( name ):= [ r ];
fi;
if IsHPCGAP then
# FIXME: we make the package info record immutable, to
# FIXME: we make the package info record readonly, to
# allow access from multiple threads; but that in turn
# can break packages, which rely on their package info
# record being readable (see issue #2568)
MakeImmutable( record.( name ) );
MakeReadOnlyObj( record.( name ) );
fi;
od;
GAPInfo.PackagesInfo:= AtomicRecord(record);
Expand Down

0 comments on commit 758a08c

Please sign in to comment.