open.mp icon indicating copy to clipboard operation
open.mp copied to clipboard

FlatHashSet<StringView>.emplace error on x64

Open ikkentim opened this issue 1 year ago • 6 comments

Describe the bug When adding a command name to the commands set, I get a debug assertion when running the cmdlist command. This only happens on x64. It works fine on x86.

To Reproduce Tested on Windows

void onConsoleCommandListRequest(FlatHashSet<StringView>& commands)
{
    commands.emplace("foobar");
}

(repro repo https://github.com/ikkentim/open.mp-repro-x64-error/blob/ea41b85c3a49423b1b71bb2d0285e30706a9b029/main.cpp#L55C1-L58C3 )

  • run the cmdlist command in the server console
---------------------------
Microsoft Visual C++ Runtime Library
---------------------------
Debug Assertion Failed!

Program: D:\openmp\x64\omp-server.exe
File: minkernel\crts\ucrt\src\appcrt\heap\debug_heap.cpp
Line: 904

Expression: _CrtIsValidHeapPointer(block)

For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.

(Press Retry to debug the application)

---------------------------
Abort   Retry   Ignore   
---------------------------
ntdll.dll!00007ffb7308a412()
ntdll.dll!00007ffb7304cf3c()
ntdll.dll!00007ffb72fee1f5()
KernelBase.dll!00007ffb70cb4efb()
ucrtbased.dll!00007ffa8294e852()
ucrtbased.dll!00007ffa8294ca91()
ucrtbased.dll!00007ffa82950275()
ucrtbased.dll!00007ffa82950988()
test.dll!robin_hood::detail::NodeAllocator<nonstd::sv_lite::basic_string_view<char,std::char_traits<char>>,4,16384,1>::addOrFree(void * ptr, unsigned __int64 q) Line 551
test.dll!robin_hood::detail::Table<1,80,nonstd::sv_lite::basic_string_view<char,std::char_traits<char>>,void,robin_hood::hash<nonstd::sv_lite::basic_string_view<char,std::char_traits<char>>,void>,std::equal_to<nonstd::sv_lite::basic_string_view<char,std::char_traits<char>>>>::rehashPowerOfTwo(unsigned __int64 numBuckets, bool forceFree) Line 2247
test.dll!robin_hood::detail::Table<1,80,nonstd::sv_lite::basic_string_view<char,std::char_traits<char>>,void,robin_hood::hash<nonstd::sv_lite::basic_string_view<char,std::char_traits<char>>,void>,std::equal_to<nonstd::sv_lite::basic_string_view<char,std::char_traits<char>>>>::increase_size() Line 2455
test.dll!robin_hood::detail::Table<1,80,nonstd::sv_lite::basic_string_view<char,std::char_traits<char>>,void,robin_hood::hash<nonstd::sv_lite::basic_string_view<char,std::char_traits<char>>,void>,std::equal_to<nonstd::sv_lite::basic_string_view<char,std::char_traits<char>>>>::insertKeyPrepareEmptySpot<const nonstd::sv_lite::basic_string_view<char,std::char_traits<char>> &>(const nonstd::sv_lite::basic_string_view<char,std::char_traits<char>> & key) Line 2366
test.dll!robin_hood::detail::Table<1,80,nonstd::sv_lite::basic_string_view<char,std::char_traits<char>>,void,robin_hood::hash<nonstd::sv_lite::basic_string_view<char,std::char_traits<char>>,void>,std::equal_to<nonstd::sv_lite::basic_string_view<char,std::char_traits<char>>>>::emplace<std::string &>(std::string & args) Line 1800
test.dll!TestComponent::onConsoleCommandListRequest(robin_hood::detail::Table<1,80,nonstd::sv_lite::basic_string_view<char,std::char_traits<char>>,void,robin_hood::hash<nonstd::sv_lite::basic_string_view<char,std::char_traits<char>>,void>,std::equal_to<nonstd::sv_lite::basic_string_view<char,std::char_traits<char>>>> & commands) Line 85

Expected behavior No error, a list of available commands in the console window

Commit hash in master 4c5372132e08bce1b28489ee12be738f6bb24d98

specifically this build https://github.com/openmultiplayer/open.mp/actions/runs/7776007038 : open.mp-win-x64-v1.2.0.2670-1-g4c537213

ikkentim avatar Feb 16 '24 21:02 ikkentim

Are you building the component with the debug runtime (/MDd)?

Hual avatar Feb 17 '24 07:02 Hual

Ah yes, I was building with debug runtime. I build it with release runtime now and it's fine. Turns out I'm just an idiot.

Thanks for you help :)

ikkentim avatar Feb 17 '24 14:02 ikkentim

This should still be improved

Hual avatar Mar 08 '24 06:03 Hual

@ikkentim Close if done

PazzOnee avatar Jul 21 '24 15:07 PazzOnee

I had closed it. @Hual should this remain open?

ikkentim avatar Jul 21 '24 15:07 ikkentim

Yes, I reopened it for a purpose because it's a symptom of malloc/free discrepancy in the SDK which shouldn't happen

Hual avatar Jul 21 '24 16:07 Hual