Skip to content

Commit

Permalink
mktables: Don't destroy a data structure too soon.
Browse files Browse the repository at this point in the history
It can happen that one table depends on another table for its
contents.  This adds a crude mechanism to prevent the depended-upon
table from being destroyed prematurely.  So far this has only shown up
during debugging, but it could have happened generally.
  • Loading branch information
khwilliamson committed May 9, 2016
1 parent b82bf1a commit fe427a6
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
2 changes: 1 addition & 1 deletion charclass_invlists.h
Expand Up @@ -87887,7 +87887,7 @@ static const U8 WB_table[19][19] = {
* 1a0687fb9c6c4567e853913549df0944fe40821279a3e9cdaa6ab8679bc286fd lib/unicore/extracted/DLineBreak.txt
* 40bcfed3ca727c19e1331f6c33806231d5f7eeeabd2e6a9e06a3740c85d0c250 lib/unicore/extracted/DNumType.txt
* a18d502bad39d527ac5586d7bc93e29f565859e3bcc24ada627eff606d6f5fed lib/unicore/extracted/DNumValues.txt
* b2f25082bf2c632b3aa17e17fa480a068ad560868ddd51aebc281143b68ea1aa lib/unicore/mktables
* a054c7cdbdc57cf0a8ffb16b0b4944800df23fd6d76fc3c46ba58c5d2b38baf0 lib/unicore/mktables
* 462c9aaa608fb2014cd9649af1c5c009485c60b9c8b15b89401fdc10cf6161c6 lib/unicore/version
* 913d2f93f3cb6cdf1664db888bf840bc4eb074eef824e082fceda24a9445e60c regen/charset_translations.pl
* 12bd58cb9d5a99f631ca95e269f7f9c90dacaf81020efa5d95a995f3cdc19200 regen/mk_invlists.pl
Expand Down
41 changes: 39 additions & 2 deletions lib/unicore/mktables
Expand Up @@ -5430,6 +5430,15 @@ sub trace { return main::trace(@_); }
# used to override calculations.
main::set_access('format', \%format, 'r', 'p_s');

my %has_dependency;
# A boolean that gives whether some other table in this property is
# defined as the complement of this table. This is a crude, but currently
# sufficient, mechanism to make this table not get destroyed before what
# is dependent on it is. Other dependencies could be added, so the name
# was chosen to reflect a more general situation than actually is
# currently the case.
main::set_access('has_dependency', \%has_dependency, 'r', 's');

sub new {
# All arguments are key => value pairs, which you can see below, most
# of which match fields documented above. Otherwise: Re_Pod_Entry,
Expand Down Expand Up @@ -5485,6 +5494,7 @@ sub trace { return main::trace(@_); }
$note{$addr} = [ ];
$file_path{$addr} = [ ];
$locked{$addr} = "";
$has_dependency{$addr} = 0;

push @{$description{$addr}}, $description if $description;
push @{$note{$addr}}, $note if $note;
Expand Down Expand Up @@ -8168,6 +8178,15 @@ sub trace { return main::trace(@_); }
}
my $addr = do { no overloading; pack 'J', $self; };
$complement{$addr} = $other;

# Be sure the other property knows we are depending on them; or the
# other table if it is one in the current property.
if ($self->property != $other->property) {
$other->property->set_has_dependency(1);
}
else {
$other->set_has_dependency(1);
}
$self->lock;
return;
}
Expand Down Expand Up @@ -8754,6 +8773,15 @@ sub trace { return main::trace(@_) if main::DEBUG && $to_trace }
main::set_access('pre_declared_maps',
\%pre_declared_maps, 'r', 's');

my %has_dependency;
# A boolean that gives whether some table somewhere is defined as the
# complement of a table in this property. This is a crude, but currently
# sufficient, mechanism to make this property not get destroyed before
# what is dependent on it is. Other dependencies could be added, so the
# name was chosen to reflect a more general situation than actually is
# currently the case.
main::set_access('has_dependency', \%has_dependency, 'r', 's');

sub new {
# The only required parameter is the positionally first, name. All
# other parameters are key => value pairs. See the documentation just
Expand Down Expand Up @@ -8792,6 +8820,7 @@ sub trace { return main::trace(@_) if main::DEBUG && $to_trace }
$has_only_code_point_maps{$addr} = 1;
$table_ref{$addr} = { };
$unique_maps{$addr} = { };
$has_dependency{$addr} = 0;

$map{$addr} = Map_Table->new($name,
Full_Name => $full_name{$addr},
Expand Down Expand Up @@ -18558,8 +18587,16 @@ sub make_property_test_script() {

# Sort these so get results in same order on different runs of this
# program
foreach my $property (sort { $a->name cmp $b->name } property_ref('*')) {
foreach my $table (sort { $a->name cmp $b->name } $property->tables) {
foreach my $property (sort { $a->has_dependency <=> $b->has_dependency
or
lc $a->name cmp lc $b->name
} property_ref('*'))
{
foreach my $table (sort { $a->has_dependency <=> $b->has_dependency
or
lc $a->name cmp lc $b->name
} $property->tables)
{

# Find code points that match, and don't match this table.
my $valid = $table->get_valid_code_point;
Expand Down
2 changes: 1 addition & 1 deletion regcharclass.h
Expand Up @@ -1895,7 +1895,7 @@
* 1a0687fb9c6c4567e853913549df0944fe40821279a3e9cdaa6ab8679bc286fd lib/unicore/extracted/DLineBreak.txt
* 40bcfed3ca727c19e1331f6c33806231d5f7eeeabd2e6a9e06a3740c85d0c250 lib/unicore/extracted/DNumType.txt
* a18d502bad39d527ac5586d7bc93e29f565859e3bcc24ada627eff606d6f5fed lib/unicore/extracted/DNumValues.txt
* b2f25082bf2c632b3aa17e17fa480a068ad560868ddd51aebc281143b68ea1aa lib/unicore/mktables
* a054c7cdbdc57cf0a8ffb16b0b4944800df23fd6d76fc3c46ba58c5d2b38baf0 lib/unicore/mktables
* 462c9aaa608fb2014cd9649af1c5c009485c60b9c8b15b89401fdc10cf6161c6 lib/unicore/version
* 913d2f93f3cb6cdf1664db888bf840bc4eb074eef824e082fceda24a9445e60c regen/charset_translations.pl
* d9c04ac46bdd81bb3e26519f2b8eb6242cb12337205add3f7cf092b0c58dccc4 regen/regcharclass.pl
Expand Down

0 comments on commit fe427a6

Please sign in to comment.