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

Documented bug in sign-extension behavior of opcodes OP_AND, OP_OR, and OP_XOR #1868

Merged
merged 1 commit into from Sep 28, 2012
Merged

Documented bug in sign-extension behavior of opcodes OP_AND, OP_OR, and OP_XOR #1868

merged 1 commit into from Sep 28, 2012

Conversation

maaku
Copy link
Contributor

@maaku maaku commented Sep 25, 2012

Due to a bug in the implementation of MakeSameSize(), using OP_AND, OP_OR, or OP_XOR with signed values of unequal size will result in the sign-bit becoming part of the smaller integer, with nonsensical results. This patch documents the unexpected behavior and provides the basis of a solution should decision be made to fix the bug in the future.

…nd OP_XOR.

Due to a bug in the implementation of MakeSameSize(), using OP_AND, OP_OR, or OP_XOR with signed values of unequal size will result in the sign-value becoming part of the smaller integer, with nonsensical results. This patch documents the unexpected behavior and provides the basis of a solution should decision be made to fix the bug in the future.
@laanwj
Copy link
Member

laanwj commented Sep 26, 2012

Good catch

@BitcoinPullTester
Copy link

Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/95d7f002957a7bb30a2d5d8b07fe8fe3c1f37ec0 for binaries and test log.

@gavinandresen
Copy link
Contributor

I don't like keeping dead code in source files, so I think the right thing to do is to remove MakeSameSize and the code for all of the disabled opcodes from the big switch() statement.

If we ever resurrect them git will have the history, and, I assume, we'll write thorough unit tests to make sure they actually work correctly.

So: I'd be ok with pulling this, and then another commit that removed code related to all the disabled opcodes.

@jgarzik
Copy link
Contributor

jgarzik commented Sep 26, 2012

That's what I said on IRC: delete 'em. It is dead code that requires a hard fork to re-enable.

@laanwj
Copy link
Member

laanwj commented Sep 26, 2012

Agree with Gavin, let's pull this as a warning to people if they'll ever resurrect this code, and then in a later pull remove all the code related to disabled opcodes. At the moment, they are only confusing.

@gmaxwell
Copy link
Contributor

@laanwj sounds like a plan.

@maaku
Copy link
Contributor Author

maaku commented Sep 26, 2012

I will create a new pull-request that surgically removes the disabled opcodes (they will now be caught by the default: return false catch-all).

EDIT: Sorry for the messy commit references surrounding this comment. Github refuses to forget about amended/removed commits :\

laanwj added a commit that referenced this pull request Sep 28, 2012
Documented bug in sign-extension behavior of opcodes OP_AND, OP_OR, and OP_XOR
@laanwj laanwj merged commit 035cb47 into bitcoin:master Sep 28, 2012
@xanatos
Copy link

xanatos commented Apr 26, 2013

Just a question... Isn't the proposed patch "wrong"? Negative numbers should be padded with 0xFF, not with 0. For example, in Little Endian, a 16 bit -1 is 0xFFFF, at 24 bits it's 0xFFFFFF, at 32 bits it's 0xFFFFFF. -2 at 16 bits is 0xFEFF, at 24 bits it's 0xFEFFFF...

@maaku
Copy link
Contributor Author

maaku commented Apr 26, 2013

Bitcoin uses its own big-endian, explicit-bit semantics for BigNums.

KolbyML pushed a commit to KolbyML/bitcoin that referenced this pull request Dec 5, 2020
…s_wallet to obtain the collateral.

7f86031 wallet: GetMasternodeVinAndKeys was not locking cs_wallet to obtain the collateral tx. (furszy)

Pull request description:

  Fixing `CWallet::GetMasternodeVinAndKeys` accessing `mapWallet` without locking `cs_wallet`.
  Decoupled from bitcoin#1829 .

ACKs for top commit:
  random-zebra:
    utACK 7f86031
  Fuzzbawls:
    utACK 7f86031

Tree-SHA512: 34995e3d65d6506d4a2465dd41b6d710d8a3e34f613a88691b6aa53018afa48a000faa444d03bbca0f418126fd5220a416d85a5a81d2053fd1412159b8cfb3c9
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants