concurrentqueue icon indicating copy to clipboard operation
concurrentqueue copied to clipboard

Are there any specific prerequisites for using (e.g., hardware, compiler, runtime libraries)?moodycamel::ConcurrentQueue

Open 2448545222 opened this issue 1 year ago • 1 comments

Description

I encountered an issue where the test program runs fine on some computers but crashes after displaying the message box "1" on others. Initially, I suspected it might be related to the Windows version, as the program crashed on two Windows 10 machines but worked perfectly on my development machine (Windows 11).

However, further testing showedinconsistent behavior:

  • The program works on three additional Windows 11 machines.
  • It crashes on a fourth Windows 11 machine, similar to the behavior on Windows 10 systems.

Given these results, it seems unlikely that the issue is directly tied to the operating system version. Are there any specific prerequisites or system conditions required for using the library? Any insights or suggestions for debugging this issue would be greatly appreciated.moodycamel::ConcurrentQueue

Environment

  • Library: moodycamel::ConcurrentQueue

  • Program architecture: x86

  • Development machine: Windows 11 (works correctly)

  • Affected systems: Mixed (Windows 10 and Windows 11)

  • Testing setup: Basic usage example with multithreading () and _beginthreadexConcurrentQueue

  • Compiler Settings:

    • Language standard: Preview - Features from the Latest C++ Working Draft (/std:c++latest)

Steps to Reproduce

Compile the program using the provided code example (attached below). Run the program on different systems with various Windows versions.

Observed Behavior

On some systems, the program crashes immediately after showing the message box "1". On others, it works as expected.

Expected Behavior

The program should enqueue and dequeue items without crashing on all systems.

#include <Windows.h>
#include "concurrentqueue.h"

void CheckExitProcess()
{
    if (GetAsyncKeyState(VK_END) & 0x8000) {
        ExitProcess(0);
    }
}

class TestItem
{
public:
};

moodycamel::ConcurrentQueue<std::unique_ptr<TestItem>> TestQueue;

unsigned __stdcall TaskTest(LPVOID lp)
{
    while (true)
    {
        CheckExitProcess();
        auto newSnapshot = std::make_unique<TestItem>();
        MessageBoxA(0, "1", "", 0); // A message box displaying "1" will pop up
        TestQueue.enqueue(move(newSnapshot)); // Program crashes here because "2" does not appear
        MessageBoxA(0, "2", "", 0);
    }
}

int main()
{
    HANDLE hThread = reinterpret_cast<HANDLE>(_beginthreadex(nullptr, 0u, TaskTest, nullptr, 0u, nullptr));
    while (true)
    {
        CheckExitProcess();
        std::unique_ptr<TestItem> item1;
        if (TestQueue.try_dequeue(item1))
        {
            auto aaaaa = move(item1);
        }
    };
}

Questions

  • Are there any specific prerequisites for using (e.g., hardware, compiler, runtime libraries)?moodycamel::ConcurrentQueue

2448545222 avatar Dec 01 '24 12:12 2448545222

This is not normal, no. Unfortunately I don't have time to try to reproduce right now.

cameron314 avatar Dec 07 '24 19:12 cameron314