Bug: NULL pointer dereference in RecoverShardStatistic() - malloc return value unchecked
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Newbie friendliness
- 1/100
Research direction
The issue identifies src/backend/pgxc/shard/shardmap.c and RecoverShardStatistic() as the entry point. Read the allocation and subsequent read(fd, rec, size) call, then check the project's existing handling for allocation failures. Done means the NULL allocation is handled safely so recovery cannot pass it to read(); the issue links fix PR #276.
Written by the indexing model from the issue text.
Description
Bug Description
In src/backend/pgxc/shard/shardmap.c, the RecoverShardStatistic() function calls malloc() to allocate a ShardRecord array of MAX_SHARDS * sizeof(ShardRecord) bytes, but never checks the return value. If malloc() returns NULL (out of memory), the subsequent read(fd, rec, size) call will write to a NULL pointer, causing a segmentation fault (SIGSEGV).
Reproduction
// Line 3355-3358
int size = sizeof(ShardRecord) * nelems; // nelems = MAX_SHARDS (large allocation)
ShardRecord *rec = (ShardRecord *)malloc(size);
// No NULL check!
// ...
ret = read(fd, rec, size); // NULL deref if malloc fails -> SIGSEGV
Impact
- Severity: High — causes process crash (segfault)
- Component: PGXC shard management
- Trigger: Memory pressure / OOM condition during shard statistic recovery
- Effect: Backend process crash
Fix PR
#276
- Dominant language
- C
- Stars
- 946
- Forks
- 693
- Avg merge
- 5m
- Merged PRs (30d)
- 1
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from OpenTenBase/OpenTenBase
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
OpenTenBase/OpenTenBase#557 ·
Maintainers usually reply within 1 day
-
otb-health: 健康检查永远以退出码 0 结束,检查失败无法被发现Possibly taken @shibuchou claimed this 20 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
OpenTenBase/OpenTenBase#503 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 1-3 hours Newbie friendliness 72/100
OpenTenBase/OpenTenBase#319 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
OpenTenBase/OpenTenBase#541 ·
Maintainers usually reply within 1 day
-
7Open
Difficulty 5/5 Over a week Newbie friendliness 15/100
OpenTenBase/OpenTenBase#524 ·
Maintainers usually reply within 1 day
All issues in OpenTenBase/OpenTenBase
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
libsdl-org/SDL#16837 ·
Maintainers usually reply within 1 day
-
Claude:NeedsReview GPT:ConfirmedBug GPT:NeedsReview triage
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
open5gs/open5gs#5141 · 2 comments ·
Maintainers usually reply within 1 day
-
CI: MSYS2 jobs fail — mingw python3 package renamed upstream to pythonPossibly taken @ronaldtse claimed this today. Open
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
bug good first issue
Difficulty 1/5 Under an hour Newbie friendliness 85/100
TanvirHasanAkash/CSE114-Lab-Project-72_B2_G2#37 ·
Maintainers usually reply within 1 day
-
issue: bug report
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 2 days