Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit341e9a0

Browse files
committed
Fix two NULL pointer dereferences when reading custom pgstats from file
There were two spots in pgstat_read_statsfile() where is was possible tofinish with a null-pointer-dereference crash for custom pgstats kinds:- When reading stats for a fixed-numbered stats entry.- When reading a variable stats entry with name serialization.For both cases, these issues were reachable by starting a server afterchanging shared_preload_libraries so as the stats written previouslycould not be loaded.The code is changed so as the stats are ignored in this case, like theother code paths doing similar sanity checks. Two WARNINGs are added tobe able to debug these issues. A test is added for the case offixed-numbered stats with the module injection_points.Oversights in7949d95, spotted while looking at a different report.Discussion:https://postgr.es/m/Ztj0Jftsn4xXuXtl@paquier.xyz
1 parent5735521 commit341e9a0

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

‎src/backend/utils/activity/pgstat.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1781,6 +1781,12 @@ pgstat_read_statsfile(XLogRecPtr redo)
17811781
}
17821782

17831783
info=pgstat_get_kind_info(kind);
1784+
if (!info)
1785+
{
1786+
elog(WARNING,"could not find information of kind %u for entry of type %c",
1787+
kind,t);
1788+
gotoerror;
1789+
}
17841790

17851791
if (!info->fixed_amount)
17861792
{
@@ -1861,6 +1867,12 @@ pgstat_read_statsfile(XLogRecPtr redo)
18611867
}
18621868

18631869
kind_info=pgstat_get_kind_info(kind);
1870+
if (!kind_info)
1871+
{
1872+
elog(WARNING,"could not find information of kind %u for entry of type %c",
1873+
kind,t);
1874+
gotoerror;
1875+
}
18641876

18651877
if (!kind_info->from_serialized_name)
18661878
{

‎src/test/modules/injection_points/t/001_stats.pl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,10 @@
6969
"SELECT * FROM injection_points_stats_fixed();");
7070
is($fixedstats,'0|0|0|0|0','fixed stats after crash');
7171

72+
# Stop the server, disable the module, then restart. The server
73+
# should be able to come up.
74+
$node->stop;
75+
$node->adjust_conf('postgresql.conf','shared_preload_libraries',"''");
76+
$node->start;
77+
7278
done_testing();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp