facebook / facebook/rocksdb

Bug Segmentation fault occurs because input Option compaction_style is not satinized

Open
#10,957 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
32.1k
Forks
6.9k
Avg merge
32m
Merged PRs (30d)
1

Description

### Expected behavior
When option compaction_style is set to 5 or bigger by the user, rocksdb should santinize user's input or just raise Status::InvalidArgument because there are only 4 compaction styles.

### Actual behavior
However, DB could accept the options.compaction_style =5.

Rocksdb could run successfully for a while and will crash as "Segmentation fault (core dumped)" until it occurs compaction.

Also, set compaction_style to negative integer will trigger this bug as same reason.

### Steps to reproduce the behavior
Just run db_bench like below:
`./db_bench --benchmarks=fillrandom --compression_type=none --compaction_style=5 --num=5000000`

After running a while, Segmentation fault (core dumped) occurs.

Contributor guide

Open the contributing guide

Research direction

Reproduce the crash with the provided db_bench command, then trace how the compaction_style option is parsed and used during compaction. Check the existing option-validation behavior for values outside the four supported styles. Done means invalid values are sanitized or rejected with Status::InvalidArgument, and the reproducer no longer segfaults.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.