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

segfault in try_dequeue #328

Open
tesla1060 opened this issue Jan 6, 2023 · 1 comment
Open

segfault in try_dequeue #328

tesla1060 opened this issue Jan 6, 2023 · 1 comment

Comments

@tesla1060
Copy link

tesla1060 commented Jan 6, 2023

Hi,
I am getting a segfault in my code, it is a multi-thread program, the core dump is as below,

(gdb) bt full
#0  0x0000000000441540 in try_dequeue<std::shared_ptr<Frame> > (item=<synthetic pointer>, this=0xbe3c50) at /root/projects/active/user/include/third_party/concurrentqueue.h:1111
        nonEmptyCount = 0
        best = 0x0
        bestSize = 0
#1  ConsumerNice::listening_nice (this=0xbe3c40) at /root/projects/active/user/include/concurrency/consumer_nice.h:45
        frame = std::shared_ptr (empty) 0x0
#2  0x00000000004c0530 in execute_native_thread_routine ()
No symbol table info available.
#3  0x00007f3eb3f81e65 in start_thread () from /lib64/libpthread.so.0
No symbol table info available.
#4  0x00007f3ead70a88d in clone () from /lib64/libc.so.6
No symbol table info available.

My code is as below:

    void listening_nice() {
        while (true) {
            std::shared_ptr<Frame> frame;
            if (nice_queue.try_dequeue(frame)) {
                on_frame_nice(frame);
            }
        }
    }

I look at concurrentqueue.h:1111,

	bool try_dequeue(U& item)
	{
		// Instead of simply trying each producer in turn (which could cause needless contention on the first
		// producer), we score them heuristically.
		size_t nonEmptyCount = 0;
		ProducerBase* best = nullptr;
		size_t bestSize = 0;
		for (auto ptr = producerListTail.load(std::memory_order_acquire); nonEmptyCount < 3 && ptr != nullptr; ptr = ptr->next_prod()) {
			auto size = ptr->size_approx();
			if (size > 0) {
				if (size > bestSize) {
					bestSize = size;
					best = ptr;
				}
				++nonEmptyCount;
			}
		}

didnt see why it has segfault.

@cameron314
Copy link
Owner

How is nice_queue created? When is it destructed? What is the producer thread doing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants