cameron314 / cameron314/concurrentqueue

explicite producer inner call set_many_empty lead to assert(false)

Open
#330 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
12.5k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

	inline bool set_many_empty(MOODYCAMEL_MAYBE_UNUSED index_t i, size_t count)
	{
		MOODYCAMEL_CONSTEXPR_IF (context == explicit_context && BLOCK_SIZE <= EXPLICIT_BLOCK_EMPTY_COUNTER_THRESHOLD) {
			// Set flags
			std::atomic_thread_fence(std::memory_order_release);
			i = BLOCK_SIZE - 1 - static_cast<size_t>(i & static_cast<index_t>(BLOCK_SIZE - 1)) - count + 1;
			for (size_t j = 0; j != count; ++j) {
				assert(!emptyFlags[i + j].load(std::memory_order_relaxed));  @marked 1
				emptyFlags[i + j].store(true, std::memory_order_relaxed);
			}
			return false;
		}
		else {
			// Increment counter
			auto prevVal = elementsCompletelyDequeued.fetch_add(count, std::memory_order_release);
			assert(prevVal + count <= BLOCK_SIZE);
			return prevVal + count == BLOCK_SIZE;
		}
	}

code at @marked 1, if the block has been marked true, it will trigger assert(false) and coredump the program. i wonder:

  1. how can it be?
  2. can comment such code, actually, the block just marked rue once more

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing set_many_empty and the emptyFlags assertion at the marked line, then inspect how explicit producers mark and reuse blocks. Reproduce the reported assertion if possible and determine whether repeated marking is valid before deciding whether the assertion or surrounding state transition needs changing.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.