Skip to content

Fix three bugs#832

Merged
fnordspace merged 5 commits intoqubic:developfrom
fnordspace:bugfix/2026-04-12-FixBugs
Apr 13, 2026
Merged

Fix three bugs#832
fnordspace merged 5 commits intoqubic:developfrom
fnordspace:bugfix/2026-04-12-FixBugs

Conversation

@fnordspace
Copy link
Copy Markdown
Contributor

This PR fixes three bugs

  1. src/logging/net_msg_impl.h removal of a double sizeof operator which always returns 8
  2. src/common_buffers.h Consequently use bytes as locks for subBufferLocks to avoid race conditions and overwritting of OOB memory
  3. src/contract_core/qpi_collection_impl.h Add stackBytes to allocation to avoid writing to uninitialized and potentially used memory

@fnordspace fnordspace self-assigned this Apr 12, 2026
@fnordspace fnordspace added the bug Something isn't working label Apr 12, 2026
@fnordspace fnordspace added this to qubic Apr 12, 2026
@fnordspace fnordspace moved this to 👀 In review in qubic Apr 12, 2026
Copy link
Copy Markdown
Contributor

@philippwerner philippwerner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! These are some very good finds!

subBufferSize = size;
subBufferPtr = (unsigned char**)buffer;
subBufferLock = (volatile char*)(buffer + ptrSize);
setMem((void*)subBufferLock, lockSize, 0);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't needed, because allocPoolWithErrorLog() initializes the buffer with 0 already.

constexpr unsigned long long defaultCommonBuffersSize = math_lib::max(MAX_CONTRACT_STATE_SIZE, math_lib::max(spectrumSizeInBytes, universeSizeInBytes));
constexpr unsigned long long spectrumSizeInBytes = SPECTRUM_CAPACITY * sizeof(EntityRecord);
constexpr unsigned long long universeSizeInBytes = ASSETS_CAPACITY * sizeof(AssetRecord);
constexpr unsigned long long defaultCommonBuffersSize = math_lib::max(MAX_CONTRACT_STATE_SIZE, math_lib::max(spectrumSizeInBytes, universeSizeInBytes));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please avoid these diffs (also see setMem(ptr, size, 0); before) that are due to whitespace changes only in future bugfix/feature PRs. I usually build my commit with git add -p to avoid including such things.

Code reformatting ideally should be done in extra PRs.

@fnordspace fnordspace merged commit b3e450e into qubic:develop Apr 13, 2026
1 check passed
@github-project-automation github-project-automation bot moved this from 👀 In review to ✅ Done in qubic Apr 13, 2026
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

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

2 participants