-
Notifications
You must be signed in to change notification settings - Fork 101
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
race condition with blockchain.New() writing to wire package variables #102
Comments
This was a change I made as part of Bitcoin Cash consensus rules. The Maybe use a |
Oops sorry about that. I can take a look at a better way to do this tonight. |
@emergent-reasons want to try and fix this one? |
I will take a look. |
Here is what I found: As Chris said, There is an additional bug where I came up with a few solutions. If you have a preference or a better solution, please let me know. For now, I will try out 3 to help me learn how much coupling there is.
|
I would investigate 3 and 4. Those seem like most logical options. |
Intermediate results of threading ExcessiveBlockSize into the
Har har. Abandon ship. It turns out that the excessiveBlockSize value reaches into just about every function of the |
@emergent-reasons fwiw I don't think we ever expect to change the excessiveblocksize while running |
Thank you Chris. I didn't think so either. The only gotcha I thought of is that if somebody starts the node with a command line arg for EBS, then the CLI would need to query the server to be sure to have the right behavior. Not sure how big a deal that is. |
Before trying 4. (moving config into a package), I wanted to see what would happen with the easy way 5. (initializing the variable and wrapping with a getter). It revealed that a lot of the wire limits were static and incorrect. Rather, they were correct but only for EBS of 32,000,000. So there were some failures and worse, some incorrect passes when EBS is changed to another value. This minimal implementation of 5. (initializing + getter) seems to do the job but it touches a lot of code and as predicted it's a mess due to the requirement of initializing If anyone has a minute for critique it would be nice, but I am not planning to PR this. I will try the solution of moving config into it's own package next. |
I hesitate to file this. Maybe it is good to be searchable and it also might show a class of race conditions involving package level variables.
The race detector (
go test -race ./...
) found a race condition:blockchain.New()
sets some variables in thewire
package.wire.MaxMessagePayload
being read and written by two different tests.That wouldn't matter if, for example,
blockchain.New()
is only called once, but I found it it used in:cmd/addblock/import.go
cmd/findcheckoint/findcheckpoint.go
server.go
So there is a remote chance of mangled data using those commands. There also might be a class of problems with package variables.
The text was updated successfully, but these errors were encountered: