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

consensus/ticket/ticket.go的delTicket() 偶发出现越界 #51

Closed
chain33-shg opened this issue Nov 21, 2018 · 0 comments · Fixed by #52
Closed

consensus/ticket/ticket.go的delTicket() 偶发出现越界 #51

chain33-shg opened this issue Nov 21, 2018 · 0 comments · Fixed by #52
Labels
bug Something isn't working

Comments

@chain33-shg
Copy link
Contributor

问题代码文件: plugin/consensus/ticket/ticket.go
问题代码:

func (client *Client) delTicket(ticket *ty.Ticket, index int) {
	client.ticketmu.Lock()
	defer client.ticketmu.Unlock()
	//1. 结构体没有被重新调整过
	oldticket := client.tlist.Tickets[index]  // <--- 这里的index可能出现越界、过期index的情况
        ....
}

问题描述:
client.delTicket(ticket, index)的index参数通过Miner下的client.searchTargetTicket(parent, block)操作获取。
操作对象为client.tlist.Tickets, 该对象在运行过程中存在多个协程共同操作的现象,会导致client.searchTargetTicket返回的Index已经被其他协程删除、或者被调整,可能会引起数据处理错误甚至程序崩溃。

@vipwzw vipwzw added the bug Something isn't working label Nov 21, 2018
chain33-shg added a commit to chain33-shg/plugin that referenced this issue Nov 21, 2018
调整保存Ticket列表的容器结构,由slice修改为map,修复了随机访问时可能出现的崩溃问题,提高了搜索效率。
vipwzw pushed a commit that referenced this issue Nov 21, 2018
调整保存Ticket列表的容器结构,由slice修改为map,修复了随机访问时可能出现的崩溃问题,提高了搜索效率。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants