Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

是否存在空指针partition先访问后判断的问题? #1410

Closed
fly1ngpengu1ns opened this issue Apr 29, 2023 · 4 comments
Closed

是否存在空指针partition先访问后判断的问题? #1410

fly1ngpengu1ns opened this issue Apr 29, 2023 · 4 comments

Comments

@fly1ngpengu1ns
Copy link
Contributor

您好!我在阅读源码时发现,在https://github.com/OpenAtomFoundation/pika/blob/unstable/src/pika_server.cc#L988 中,存在着下面这样的代码:
image
这里partition是NULL的时候才会进988行的处理流程,但是这里用了partition->GetPartitionName(),使用到了空指针?
而查看partition的赋值语句std::shared_ptr<Partition> partition = GetTablePartitionById(table_name, partition_id);中调用的函数GetTablePartitionById:
image
发现他确实是可以返回NULL的,上述访问空指针的流程确实存在,但是有点不知道怎么修改?能直接输出partition_id,而不是partition_name吗?

同样的问题还出现在了https://github.com/OpenAtomFoundation/pika/blob/unstable/src/pika_server.cc#L971
https://github.com/OpenAtomFoundation/pika/blob/unstable/src/pika_server.cc#L965

@AlexStocks
Copy link
Contributor

您好!我在阅读源码时发现,在https://github.com/OpenAtomFoundation/pika/blob/unstable/src/pika_server.cc#L988 中,存在着下面这样的代码: image 这里partition是NULL的时候才会进988行的处理流程,但是这里用了partition->GetPartitionName(),使用到了空指针? 而查看partition的赋值语句std::shared_ptr<Partition> partition = GetTablePartitionById(table_name, partition_id);中调用的函数GetTablePartitionById: image 发现他确实是可以返回NULL的,上述访问空指针的流程确实存在,但是有点不知道怎么修改?能直接输出partition_id,而不是partition_name吗?

同样的问题还出现在了https://github.com/OpenAtomFoundation/pika/blob/unstable/src/pika_server.cc#L971https://github.com/OpenAtomFoundation/pika/blob/unstable/src/pika_server.cc#L965

能否加微信助手 PikiwiDB ,然后加入 微信群交流下?

@infdahai
Copy link

可以改成 std::pair<std::shared_ptr,int> 存储下指针和id

@AlexStocks
Copy link
Contributor

AlexStocks commented Apr 30, 2023

@fly1ngpengu1ns The bug really exists. Maybe you can submit a pr. Just record the table_name & partition_id in the log.

@fly1ngpengu1ns
Copy link
Contributor Author

@fly1ngpengu1ns The bug really exists. Maybe you can submit a pr. Just record the table_name & partition_id in the log.

Thanks for your support! I have submitted a PR: #1414

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants