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

Avoid Undefined Behavior in arith_uint256 #77

Closed
leto opened this issue Feb 9, 2020 · 3 comments
Closed

Avoid Undefined Behavior in arith_uint256 #77

leto opened this issue Feb 9, 2020 · 3 comments
Labels
bug Something isn't working

Comments

@leto
Copy link
Member

leto commented Feb 9, 2020

Fixed in BTC one way: bitcoin/bitcoin#14510

And in ZEC a slightly different way: zcash#4056

@oDinZu
Copy link

oDinZu commented Mar 16, 2020

What are the differences between the two implementations?

From what I have researched, it comes down to blocking and non-blocking algorithm.
Anything undefined in the programming world creates possible challenges in the future.

zcash#3792

What does arith_uint.cpp do? Is there a glossary to aid in learning various pieces in bitcoin cpp that create the whole application using the English language 😄 ? My conversion ratio of cpp and English are rusty.

Assigning a U defines a 'unsigned' integer in Cpp.

In programming Cpp, the difference between a signed short int and unsigned short int is one allows negative numbers, while the other begins from 0 to positive numbers.
https://en.cppreference.com/w/cpp/language/types

@leto
Copy link
Member Author

leto commented Mar 18, 2020

@csharpee close, but not quite. Undefined Behavior = UB means that a compiler can do anything it wants, there is no standard. It could core dump and still "follow the spec". We must avoid UB so that our code compiles anywhere and works correctly. This is not about blocking (synchronous) and non-blocking (asynchronous) : https://en.wikipedia.org/wiki/Undefined_behavior

You will need to read source code and comments to understand things about a lot of BTC internals. Sometimes the book "Mastering Bitcoin" can help, I haven't read any others. arith_uint256 are 256 bit integers with arithmetic operations, uint256 objects are just 256 bit blobs with no arithmetic operators.

@leto
Copy link
Member Author

leto commented Apr 16, 2020

Fixed

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

No branches or pull requests

2 participants