# Getting Overflow error when creating a thread

**URL:** <https://forums.unrealengine.com/t/getting-overflow-error-when-creating-a-thread/1789023>\
**Category:** C++\
**Tags:** threads, unreal-engine, crash, bug-report, editor, CPP, Blueprint, question\
**Created:** [April 5, 2024, 9:20am UTC](https://forums.unrealengine.com/t/getting-overflow-error-when-creating-a-thread/1789023 "2024-04-05T09:20:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![444\_Nuits](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/444_nuits/32/901354_2.png) [@444\_Nuits](https://forums.unrealengine.com/u/444_Nuits)\
**Post date:** [April 5, 2024, 9:20am UTC](https://forums.unrealengine.com/t/getting-overflow-error-when-creating-a-thread/1789023/1 "2024-04-05T09:20:19Z")

</div>

Hiii,

In my Character’s Blueprint, I added an event to when I press the v Key it calls this startImitation function :

```c++
void UMyCaptureComponent::startImitation()
{
	start();
}

//My Capture Comp inherits from RingBufferConsummer:

void RingBufferConsumer::start()
{
  UE_LOG(LogTemp, Warning, TEXT("RingBufferConsumer::start"));
  _doRead = true;
  _readThread = FRunnableThread::Create(new RingBufferConsumerWorker(this), TEXT("RingBufferConsumerThread"), 0U, TPri_Highest);
}

//here's the Run() Function of my thread, it's a function of my worker class inheriting from FRunnable and _instance is a pointer to my RingBufferConsummer class:

virtual uint32 Run() override {
  int32 sizeRed = 0;
  uint64 readPosition = 0;

  while (_instance->_doRead) {
    if (_instance->_ringBuffer->waitToBeginRead(_instance->_sizeToRead, readPosition)) {
      sizeRed = _instance->processData(readPosition);
      if (_instance->_doRead == false) {
        break;
      }
      if (sizeRed < 0)
        continue;
      _instance->_ringBuffer->endRead(sizeRed);
    }
  }

  return 0;
}

//For now, my processdata() function just sets _doRead to false : 
int64 UMyCaptureComponent::processData(uint64 readPosition)
{
	UE_LOG(LogTemp, Warning, TEXT("processData"));
	_doRead = false;
  return 0;
}

```

I have no Idea of why I’m getting this error I know that it is thrown when he call stack of a thread exceeds its reserved stack space and that it s can happen if there is deep recursion or if the program allocates too much stack space for local variables, function calls, or nested structures  
But I don’t see any of that here ☹

---

<div class="post-metadata">

**Author:** ![444\_Nuits](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/444_nuits/32/901354_2.png) [@444\_Nuits](https://forums.unrealengine.com/u/444_Nuits)\
**Post date:** [April 5, 2024, 12:38pm UTC](https://forums.unrealengine.com/t/getting-overflow-error-when-creating-a-thread/1789023/2 "2024-04-05T12:38:33Z")

</div>

This is fixed apparenty I just needed to implement the exit() function of my runnable object

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [May 5, 2024, 12:39pm UTC](https://forums.unrealengine.com/t/getting-overflow-error-when-creating-a-thread/1789023/3 "2024-05-05T12:39:02Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
