Skip to content

Commit fe427a6

Browse files
committed
mktables: Don't destroy a data structure too soon.
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.
1 parent b82bf1a commit fe427a6

File tree

3 files changed

+41
-4
lines changed

3 files changed

+41
-4
lines changed

charclass_invlists.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87887,7 +87887,7 @@ static const U8 WB_table[19][19] = {
8788787887
* 1a0687fb9c6c4567e853913549df0944fe40821279a3e9cdaa6ab8679bc286fd lib/unicore/extracted/DLineBreak.txt
8788887888
* 40bcfed3ca727c19e1331f6c33806231d5f7eeeabd2e6a9e06a3740c85d0c250 lib/unicore/extracted/DNumType.txt
8788987889
* a18d502bad39d527ac5586d7bc93e29f565859e3bcc24ada627eff606d6f5fed lib/unicore/extracted/DNumValues.txt
87890-
* b2f25082bf2c632b3aa17e17fa480a068ad560868ddd51aebc281143b68ea1aa lib/unicore/mktables
87890+
* a054c7cdbdc57cf0a8ffb16b0b4944800df23fd6d76fc3c46ba58c5d2b38baf0 lib/unicore/mktables
8789187891
* 462c9aaa608fb2014cd9649af1c5c009485c60b9c8b15b89401fdc10cf6161c6 lib/unicore/version
8789287892
* 913d2f93f3cb6cdf1664db888bf840bc4eb074eef824e082fceda24a9445e60c regen/charset_translations.pl
8789387893
* 12bd58cb9d5a99f631ca95e269f7f9c90dacaf81020efa5d95a995f3cdc19200 regen/mk_invlists.pl

lib/unicore/mktables

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5430,6 +5430,15 @@ sub trace { return main::trace(@_); }
54305430
# used to override calculations.
54315431
main::set_access('format', \%format, 'r', 'p_s');
54325432

5433+
my %has_dependency;
5434+
# A boolean that gives whether some other table in this property is
5435+
# defined as the complement of this table. This is a crude, but currently
5436+
# sufficient, mechanism to make this table not get destroyed before what
5437+
# is dependent on it is. Other dependencies could be added, so the name
5438+
# was chosen to reflect a more general situation than actually is
5439+
# currently the case.
5440+
main::set_access('has_dependency', \%has_dependency, 'r', 's');
5441+
54335442
sub new {
54345443
# All arguments are key => value pairs, which you can see below, most
54355444
# of which match fields documented above. Otherwise: Re_Pod_Entry,
@@ -5485,6 +5494,7 @@ sub trace { return main::trace(@_); }
54855494
$note{$addr} = [ ];
54865495
$file_path{$addr} = [ ];
54875496
$locked{$addr} = "";
5497+
$has_dependency{$addr} = 0;
54885498

54895499
push @{$description{$addr}}, $description if $description;
54905500
push @{$note{$addr}}, $note if $note;
@@ -8168,6 +8178,15 @@ sub trace { return main::trace(@_); }
81688178
}
81698179
my $addr = do { no overloading; pack 'J', $self; };
81708180
$complement{$addr} = $other;
8181+
8182+
# Be sure the other property knows we are depending on them; or the
8183+
# other table if it is one in the current property.
8184+
if ($self->property != $other->property) {
8185+
$other->property->set_has_dependency(1);
8186+
}
8187+
else {
8188+
$other->set_has_dependency(1);
8189+
}
81718190
$self->lock;
81728191
return;
81738192
}
@@ -8754,6 +8773,15 @@ sub trace { return main::trace(@_) if main::DEBUG && $to_trace }
87548773
main::set_access('pre_declared_maps',
87558774
\%pre_declared_maps, 'r', 's');
87568775

8776+
my %has_dependency;
8777+
# A boolean that gives whether some table somewhere is defined as the
8778+
# complement of a table in this property. This is a crude, but currently
8779+
# sufficient, mechanism to make this property not get destroyed before
8780+
# what is dependent on it is. Other dependencies could be added, so the
8781+
# name was chosen to reflect a more general situation than actually is
8782+
# currently the case.
8783+
main::set_access('has_dependency', \%has_dependency, 'r', 's');
8784+
87578785
sub new {
87588786
# The only required parameter is the positionally first, name. All
87598787
# other parameters are key => value pairs. See the documentation just
@@ -8792,6 +8820,7 @@ sub trace { return main::trace(@_) if main::DEBUG && $to_trace }
87928820
$has_only_code_point_maps{$addr} = 1;
87938821
$table_ref{$addr} = { };
87948822
$unique_maps{$addr} = { };
8823+
$has_dependency{$addr} = 0;
87958824

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

1855918588
# Sort these so get results in same order on different runs of this
1856018589
# program
18561-
foreach my $property (sort { $a->name cmp $b->name } property_ref('*')) {
18562-
foreach my $table (sort { $a->name cmp $b->name } $property->tables) {
18590+
foreach my $property (sort { $a->has_dependency <=> $b->has_dependency
18591+
or
18592+
lc $a->name cmp lc $b->name
18593+
} property_ref('*'))
18594+
{
18595+
foreach my $table (sort { $a->has_dependency <=> $b->has_dependency
18596+
or
18597+
lc $a->name cmp lc $b->name
18598+
} $property->tables)
18599+
{
1856318600

1856418601
# Find code points that match, and don't match this table.
1856518602
my $valid = $table->get_valid_code_point;

regcharclass.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1895,7 +1895,7 @@
18951895
* 1a0687fb9c6c4567e853913549df0944fe40821279a3e9cdaa6ab8679bc286fd lib/unicore/extracted/DLineBreak.txt
18961896
* 40bcfed3ca727c19e1331f6c33806231d5f7eeeabd2e6a9e06a3740c85d0c250 lib/unicore/extracted/DNumType.txt
18971897
* a18d502bad39d527ac5586d7bc93e29f565859e3bcc24ada627eff606d6f5fed lib/unicore/extracted/DNumValues.txt
1898-
* b2f25082bf2c632b3aa17e17fa480a068ad560868ddd51aebc281143b68ea1aa lib/unicore/mktables
1898+
* a054c7cdbdc57cf0a8ffb16b0b4944800df23fd6d76fc3c46ba58c5d2b38baf0 lib/unicore/mktables
18991899
* 462c9aaa608fb2014cd9649af1c5c009485c60b9c8b15b89401fdc10cf6161c6 lib/unicore/version
19001900
* 913d2f93f3cb6cdf1664db888bf840bc4eb074eef824e082fceda24a9445e60c regen/charset_translations.pl
19011901
* d9c04ac46bdd81bb3e26519f2b8eb6242cb12337205add3f7cf092b0c58dccc4 regen/regcharclass.pl

0 commit comments

Comments
 (0)