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

investigate the problem on MinGW #217

Draft
wants to merge 1 commit into
base: snmalloc1
Choose a base branch
from

Conversation

SchrodingerZhu
Copy link
Contributor

@SchrodingerZhu SchrodingerZhu commented Jun 23, 2020

In debug mode, I see some other errors:

  • ctz failed to return the correct result.
  • mingw gcc has no -rdynamic
  • func-first-operation failed, showing ERROR: allocator in use

@SchrodingerZhu
Copy link
Contributor Author

SchrodingerZhu commented Jun 23, 2020

Currently, I cannot fix the problem on my own. I have traced into the deallocation path. During the process, snmalloc::current_alloc_pool()->list is changed. After that, iterate() returns the list head whose in_use flag is reset.

@mjp41
Copy link
Member

mjp41 commented Jun 23, 2020

Do you have a debug stack trace of when the flag is updated? The easiest way to debug this kind of crash is with time travel debugging with "WinDBG Preview", when you get the in_use flag that fails, add a break point on that address and run backwards looking at where it is changed.

If you can post the stack traces, I can probably work it out what might be happening.

@SchrodingerZhu
Copy link
Contributor Author

stack traces of acquire (the only operation that changes list):

C:\msys64\home\JimmyZhu\snmalloc\cmake-build-debug\func-first_operation-1.exe
.Stack: 
	snmalloc::Pool<snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows> >::acquire<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>&> pool.h:50
	Thread id: 5 has terminated
Stack: 
	snmalloc::Pool<snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows> >::acquire<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>&> pool.h:50
	ntdll!RtlActivateActivationContextUnsafeFast 0x00007ffde3248c93
	ntdll!LdrShutdownThread 0x00007ffde3249ab6
	ntdll!RtlExitUserThread 0x00007ffde326435e
	msvcrt!_endthreadex 0x00007ffde2f3dea7
	pthread_create_wrapper 0x000000006494510b
	msvcrt!_beginthreadex 0x00007ffde2f3de54
	msvcrt!_endthreadex 0x00007ffde2f3df2c
	KERNEL32!BaseThreadInitThunk 0x00007ffde2118f4e
	ntdll!RtlUserThreadStart 0x00007ffde32642db
	<unknown> 0x0000000000000000
Stack: 
	snmalloc::Pool<snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows> >::acquire<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>&> pool.h:50Stack: 
	snmalloc::Pool<snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows> >::acquire<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>&> pool.h:50
	Thread id: 8 has terminated
Stack: 
	snmalloc::Pool<snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows> >::acquire<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>&> pool.h:50
	SleepEx 0x00007ffde0abb9be
	pthread_create_wrapper 0x000000006494506d
	msvcrt!_beginthreadex 0x00007ffde2f3de54
	msvcrt!_endthreadex 0x00007ffde2f3df2c
	KERNEL32!BaseThreadInitThunk 0x00007ffde2118f4e
	ntdll!RtlUserThreadStart 0x00007ffde32642db
	<unknown> 0x0000000000000000
Stack: 
	snmalloc::Pool<snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows> >::acquire<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>&> pool.h:50
	Thread id: 10 has terminated
Stack: 
	snmalloc::Pool<snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows> >::acquire<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>&> pool.h:50
	Thread id: 11 has terminated
Stack: 
	snmalloc::Pool<snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows> >::acquire<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>&> pool.h:50
	Thread id: 12 has terminated
Stack: 
	snmalloc::Pool<snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows> >::acquire<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>&> pool.h:50Stack: 
	snmalloc::Pool<snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows> >::acquire<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>&> pool.h:50
	Thread id: 13 has terminated
Stack: 
	snmalloc::Pool<snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows> >::acquire<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>&> pool.h:50
	ntdll!LdrShutdownThread 0x00007ffde3249b60
	ntdll!RtlExitUserThread 0x00007ffde326435e
	msvcrt!_endthreadex 0x00007ffde2f3dea7Stack: 
	snmalloc::Pool<snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows> >::acquire<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>&> pool.h:50
	SleepEx 0x00007ffde0abb9be
	pthread_create_wrapper 0x000000006494506d
	msvcrt!_beginthreadex 0x00007ffde2f3de54
	msvcrt!_endthreadex 0x00007ffde2f3df2cStack: 
	snmalloc::Pool<snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows> >::acquire<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>&> pool.h:50
	KERNELBASE!FlsGetValue 0x00007ffde0a9551bLazy test!
ERROR: allocator in use.
Stack: 
	snmalloc::Pool<snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows> >::acquire<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>&> pool.h:50
	Invalid thread id: 17

Process finished with exit code 3

@SchrodingerZhu
Copy link
Contributor Author

more detailed version:

C:\msys64\home\JimmyZhu\snmalloc\cmake-build-debug\func-first_operation-1.exe
.Breakpoint reached: pool.h:48
list = (snmalloc::Allocator<snmalloc::needs_initialisation, snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20, unsigned char, 0> > >, true> *) NULL
Stack: 
	Thread id: 5 has terminated
Breakpoint reached: pool.h:48
list = (snmalloc::Allocator<snmalloc::needs_initialisation, snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20, unsigned char, 0> > >, true> *) 0x17ffe4000
Stack: 
	snmalloc::Pool<snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows> >::acquire<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>&> pool.h:50
	ntdll!LdrShutdownThread 0x00007ffde3249b3b
	ntdll!RtlExitUserThread 0x00007ffde326435e
	msvcrt!_endthreadex 0x00007ffde2f3dea7
	pthread_create_wrapper 0x000000006494510b
	msvcrt!_beginthreadex 0x00007ffde2f3de54
	msvcrt!_endthreadex 0x00007ffde2f3df2c
	KERNEL32!BaseThreadInitThunk 0x00007ffde2118f4e
	ntdll!RtlUserThreadStart 0x00007ffde32642db
	<unknown> 0x0000000000000000
Breakpoint reached: pool.h:48
list = (snmalloc::Allocator<snmalloc::needs_initialisation, snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20, unsigned char, 0> > >, true> *) 0x17ffe8000
Stack: 
	snmalloc::Pool<snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows> >::acquire<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>&> pool.h:50
	ntdll!LdrShutdownThread 0x00007ffde32499f2
	ntdll!RtlExitUserThread 0x00007ffde326435e
	msvcrt!_endthreadex 0x00007ffde2f3dea7
	pthread_create_wrapper 0x000000006494510bBreakpoint reached: pool.h:48
list = (snmalloc::Allocator<snmalloc::needs_initialisation, snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20, unsigned char, 0> > >, true> *) 0x17ffec000
Stack: 
	snmalloc::Pool<snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows> >::acquire<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>&> pool.h:50
	ntdll!LdrUnloadAlternateResourceModuleEx 0x00007ffde321b0ea
	ntdll!LdrShutdownThread 0x00007ffde32499ed
	ntdll!RtlExitUserThread 0x00007ffde326435e
	msvcrt!_endthreadex 0x00007ffde2f3dea7
	pthread_create_wrapper 0x000000006494510b
	msvcrt!_beginthreadex 0x00007ffde2f3de54
	msvcrt!_endthreadex 0x00007ffde2f3df2c
	KERNEL32!BaseThreadInitThunk 0x00007ffde2118f4e
	ntdll!RtlUserThreadStart 0x00007ffde32642db
	<unknown> 0x0000000000000000
Breakpoint reached: pool.h:48
list = (snmalloc::Allocator<snmalloc::needs_initialisation, snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20, unsigned char, 0> > >, true> *) 0x17ffc0000
Stack: 
	Thread id: 9 has terminated
Breakpoint reached: pool.h:48
list = (snmalloc::Allocator<snmalloc::needs_initialisation, snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20, unsigned char, 0> > >, true> *) 0x17ffc4000
Stack: 
	snmalloc::Pool<snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows> >::acquire<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>&> pool.h:50
	ntdll!RtlActivateActivationContextUnsafeFast 0x00007ffde3248c93
	ntdll!LdrShutdownThread 0x00007ffde3249ab6
	ntdll!RtlExitUserThread 0x00007ffde326435e
	msvcrt!_endthreadex 0x00007ffde2f3dea7
	pthread_create_wrapper 0x000000006494510b
	msvcrt!_beginthreadex 0x00007ffde2f3de54
	msvcrt!_endthreadex 0x00007ffde2f3df2c
	KERNEL32!BaseThreadInitThunk 0x00007ffde2118f4e
	ntdll!RtlUserThreadStart 0x00007ffde32642db
	<unknown> 0x0000000000000000
Breakpoint reached: pool.h:48
list = (snmalloc::Allocator<snmalloc::needs_initialisation, snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20, unsigned char, 0> > >, true> *) 0x17ffc8000
Stack: 
	snmalloc::Pool<snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows> >::acquire<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>&> pool.h:50
	ntdll!LdrUnloadAlternateResourceModuleEx 0x00007ffde321b0ea
	ntdll!LdrShutdownThread 0x00007ffde32499ed
	ntdll!RtlExitUserThread 0x00007ffde326435e
	msvcrt!_endthreadex 0x00007ffde2f3dea7
	pthread_create_wrapper 0x000000006494510b
	msvcrt!_beginthreadex 0x00007ffde2f3de54
	msvcrt!_endthreadex 0x00007ffde2f3df2c
	KERNEL32!BaseThreadInitThunk 0x00007ffde2118f4e
	ntdll!RtlUserThreadStart 0x00007ffde32642db
	<unknown> 0x0000000000000000
Breakpoint reached: pool.h:48
list = (snmalloc::Allocator<snmalloc::needs_initialisation, snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20, unsigned char, 0> > >, true> *) 0x17ffcc000
Stack: 
	Invalid thread id: 12
Breakpoint reached: pool.h:48
list = (snmalloc::Allocator<snmalloc::needs_initialisation, snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20, unsigned char, 0> > >, true> *) 0x17ffd0000
Breakpoint reached: pool.h:48
list = (snmalloc::Allocator<snmalloc::needs_initialisation, snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20, unsigned char, 0> > >, true> *) 0x17ffd0000
Stack: 
	snmalloc::Pool<snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows> >::acquire<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>&> pool.h:50
	VirtualAlloc 0x00007ffde0acf2b8
	snmalloc::PALWindows::notify_using<(snmalloc::ZeroMem)0> pal_windows.h:137
	std::thread::thread<void (&)(void*, unsigned long long), void*&, unsigned long long&, void> thread:130
	f first_operation.cc:159
	main first_operation.cc:189
	__tmainCRTStartup 0x00000000004013b4
	mainCRTStartup 0x000000000040150b
Stack: 
	Thread id: 13 has terminated
Breakpoint reached: pool.h:48
list = (snmalloc::Allocator<snmalloc::needs_initialisation, snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20, unsigned char, 0> > >, true> *) 0x17ffd8000
Stack: 
	snmalloc::Pool<snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows> >::acquire<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>&> pool.h:50
	ntdll!LdrUnloadAlternateResourceModuleEx 0x00007ffde321b0ea
	ntdll!LdrShutdownThread 0x00007ffde32499ed
	ntdll!RtlExitUserThread 0x00007ffde326435e
	msvcrt!_endthreadex 0x00007ffde2f3dea7
	pthread_create_wrapper 0x000000006494510b
	msvcrt!_beginthreadex 0x00007ffde2f3de54
	msvcrt!_endthreadex 0x00007ffde2f3df2cBreakpoint reached: pool.h:48
list = (snmalloc::Allocator<snmalloc::needs_initialisation, snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20, unsigned char, 0> > >, true> *) 0x17ffdc000
Stack: 
	snmalloc::Pool<snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows> >::acquire<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>&> pool.h:50
	SleepEx 0x00007ffde0abb9be
	pthread_create_wrapper 0x000000006494506d
	msvcrt!_beginthreadex 0x00007ffde2f3de54
	msvcrt!_endthreadex 0x00007ffde2f3df2c
	KERNEL32!BaseThreadInitThunk 0x00007ffde2118f4e
	ntdll!RtlUserThreadStart 0x00007ffde32642db
	<unknown> 0x0000000000000000
Breakpoint reached: pool.h:48
list = (snmalloc::Allocator<snmalloc::needs_initialisation, snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20, unsigned char, 0> > >, true> *) 0x17ff80000
Stack: 
	Thread id: 16 has terminated
Breakpoint reached: pool.h:48
list = (snmalloc::Allocator<snmalloc::needs_initialisation, snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20, unsigned char, 0> > >, true> *) 0x17ff84000
Stack: 
	Thread id: 17 has terminated
Breakpoint reached: pool.h:75
list = (snmalloc::Allocator<snmalloc::needs_initialisation, snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20, unsigned char, 0> > >, true> *) 0x17ff88000
Lazy test!
ERROR: allocator in use.
Stack: 
	Invalid thread id: 1

Process finished with exit code 3

@mjp41
Copy link
Member

mjp41 commented Jun 23, 2020

But release changes the in_use flag as well. So that would be useful to see.

Also, are the stack traces being printed interleaved? The following looks strange. VirtualAlloc should not be calling into snmalloc.

        snmalloc::Pool<snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows> >::acquire<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>&> pool.h:50
	VirtualAlloc 0x00007ffde0acf2b8
	snmalloc::PALWindows::notify_using<(snmalloc::ZeroMem)0> pal_windows.h:137

@SchrodingerZhu
Copy link
Contributor Author

already checked release at the second log. seems it is only called once Breakpoint reached: pool.h:75.

let me check whether the output is not interrupting each other.

@SchrodingerZhu
Copy link
Contributor Author

Here is the result generated by suspending the program on each hit:

C:\msys64\home\JimmyZhu\snmalloc\cmake-build-debug\func-first_operation-1.exe
.Breakpoint reached: pool.h:48
list = (snmalloc::Allocator<snmalloc::needs_initialisation, snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20, unsigned char, 0> > >, true> *) NULL
Stack: 
	snmalloc::Pool<snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows> >::acquire<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>&> pool.h:50
	snmalloc::AllocPool<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true> >::acquire globalalloc.h:34
	snmalloc::init_thread_allocator(snmalloc::function_ref<void* (void*)>) threadalloc.h:287
	snmalloc::ThreadAllocCommon::get threadalloc.h:202
	get_test first_operation.cc:25
	std::__invoke_impl<void, void (*)()> invoke.h:60
	std::__invoke<void (*)()> invoke.h:95
	std::thread::_Invoker<std::tuple<void (*)()> >::_M_invoke<0ull> thread:244
	std::thread::_Invoker<std::tuple<void (*)()> >::operator() thread:251
	std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)()> > >::_M_run thread:195
	<unknown> 0x000000006fd42441
	pthread_create_wrapper 0x0000000064945092
	msvcrt!_beginthreadex 0x00007ffde2f3de54
	msvcrt!_endthreadex 0x00007ffde2f3df2c
	KERNEL32!BaseThreadInitThunk 0x00007ffde2118f4e
	ntdll!RtlUserThreadStart 0x00007ffde32642db
	<unknown> 0x0000000000000000
Breakpoint reached: pool.h:48
list = (snmalloc::Allocator<snmalloc::needs_initialisation, snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20, unsigned char, 0> > >, true> *) 0x17ffe4000
Stack: 
	snmalloc::Pool<snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows> >::acquire<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>&> pool.h:50
	snmalloc::AllocPool<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true> >::acquire globalalloc.h:34
	snmalloc::init_thread_allocator(snmalloc::function_ref<void* (void*)>) threadalloc.h:287
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::small_alloc_first_alloc<(snmalloc::ZeroMem)0, (snmalloc::AllowReserve)1> alloc.h:1144
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::small_alloc_rare<(snmalloc::ZeroMem)0, (snmalloc::AllowReserve)1> alloc.h:1133
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::small_alloc_next_free_list<(snmalloc::ZeroMem)0, (snmalloc::AllowReserve)1> alloc.h:1115
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::small_alloc_inner<(snmalloc::ZeroMem)0, (snmalloc::AllowReserve)1> alloc.h:1073
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::small_alloc<(snmalloc::ZeroMem)0, (snmalloc::AllowReserve)1> alloc.h:1046
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::alloc_not_small<(snmalloc::ZeroMem)0, (snmalloc::AllowReserve)1> alloc.h:193
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::alloc<(snmalloc::ZeroMem)0, (snmalloc::AllowReserve)1> alloc.h:183
	alloc1 first_operation.cc:48
	std::__invoke_impl<void, void (*)(unsigned long long), unsigned long long> invoke.h:60
	std::__invoke<void (*)(unsigned long long), unsigned long long> invoke.h:95
	std::thread::_Invoker<std::tuple<void (*)(unsigned long long), unsigned long long> >::_M_invoke<0ull, 1ull> thread:244
	std::thread::_Invoker<std::tuple<void (*)(unsigned long long), unsigned long long> >::operator() thread:251
	std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)(unsigned long long), unsigned long long> > >::_M_run thread:195
	<unknown> 0x000000006fd42441
	pthread_create_wrapper 0x0000000064945092
	msvcrt!_beginthreadex 0x00007ffde2f3de54
	msvcrt!_endthreadex 0x00007ffde2f3df2c
	KERNEL32!BaseThreadInitThunk 0x00007ffde2118f4e
	ntdll!RtlUserThreadStart 0x00007ffde32642db
	<unknown> 0x0000000000000000
Breakpoint reached: pool.h:48
list = (snmalloc::Allocator<snmalloc::needs_initialisation, snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20, unsigned char, 0> > >, true> *) 0x17ffe8000
Stack: 
	snmalloc::Pool<snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows> >::acquire<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>&> pool.h:50
	snmalloc::AllocPool<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true> >::acquire globalalloc.h:34
	snmalloc::init_thread_allocator(snmalloc::function_ref<void* (void*)>) threadalloc.h:287
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::small_alloc_first_alloc<(snmalloc::ZeroMem)0, (snmalloc::AllowReserve)1> alloc.h:1144
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::small_alloc_rare<(snmalloc::ZeroMem)0, (snmalloc::AllowReserve)1> alloc.h:1133
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::small_alloc_next_free_list<(snmalloc::ZeroMem)0, (snmalloc::AllowReserve)1> alloc.h:1115
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::small_alloc_inner<(snmalloc::ZeroMem)0, (snmalloc::AllowReserve)1> alloc.h:1073
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::small_alloc<(snmalloc::ZeroMem)0, (snmalloc::AllowReserve)1> alloc.h:1046
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::alloc_not_small<(snmalloc::ZeroMem)0, (snmalloc::AllowReserve)1> alloc.h:193
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::alloc<(snmalloc::ZeroMem)0, (snmalloc::AllowReserve)1> alloc.h:183
	alloc2 first_operation.cc:55
	std::__invoke_impl<void, void (*)(unsigned long long), unsigned long long> invoke.h:60
	std::__invoke<void (*)(unsigned long long), unsigned long long> invoke.h:95
	std::thread::_Invoker<std::tuple<void (*)(unsigned long long), unsigned long long> >::_M_invoke<0ull, 1ull> thread:244
	std::thread::_Invoker<std::tuple<void (*)(unsigned long long), unsigned long long> >::operator() thread:251
	std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)(unsigned long long), unsigned long long> > >::_M_run thread:195
	<unknown> 0x000000006fd42441
	pthread_create_wrapper 0x0000000064945092
	msvcrt!_beginthreadex 0x00007ffde2f3de54
	msvcrt!_endthreadex 0x00007ffde2f3df2c
	KERNEL32!BaseThreadInitThunk 0x00007ffde2118f4e
	ntdll!RtlUserThreadStart 0x00007ffde32642db
	<unknown> 0x0000000000000000
Breakpoint reached: pool.h:48
list = (snmalloc::Allocator<snmalloc::needs_initialisation, snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20, unsigned char, 0> > >, true> *) 0x17ffec000
Stack: 
	snmalloc::Pool<snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows> >::acquire<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>&> pool.h:50
	snmalloc::AllocPool<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true> >::acquire globalalloc.h:34
	snmalloc::init_thread_allocator(snmalloc::function_ref<void* (void*)>) threadalloc.h:287
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::small_alloc_first_alloc<(snmalloc::ZeroMem)0, (snmalloc::AllowReserve)1> alloc.h:1144
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::small_alloc_rare<(snmalloc::ZeroMem)0, (snmalloc::AllowReserve)1> alloc.h:1133
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::small_alloc_next_free_list<(snmalloc::ZeroMem)0, (snmalloc::AllowReserve)1> alloc.h:1115
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::small_alloc_inner<(snmalloc::ZeroMem)0, (snmalloc::AllowReserve)1> alloc.h:1073
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::small_alloc<(snmalloc::ZeroMem)0, (snmalloc::AllowReserve)1> alloc.h:1046
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::alloc_not_small<(snmalloc::ZeroMem)0, (snmalloc::AllowReserve)1> alloc.h:193
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::alloc<(snmalloc::ZeroMem)0, (snmalloc::AllowReserve)1> alloc.h:183
	alloc3 first_operation.cc:62
	std::__invoke_impl<void, void (*)(unsigned long long), unsigned long long> invoke.h:60
	std::__invoke<void (*)(unsigned long long), unsigned long long> invoke.h:95
	std::thread::_Invoker<std::tuple<void (*)(unsigned long long), unsigned long long> >::_M_invoke<0ull, 1ull> thread:244
	std::thread::_Invoker<std::tuple<void (*)(unsigned long long), unsigned long long> >::operator() thread:251
	std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)(unsigned long long), unsigned long long> > >::_M_run thread:195
	<unknown> 0x000000006fd42441
	pthread_create_wrapper 0x0000000064945092
	msvcrt!_beginthreadex 0x00007ffde2f3de54
	msvcrt!_endthreadex 0x00007ffde2f3df2c
	KERNEL32!BaseThreadInitThunk 0x00007ffde2118f4e
	ntdll!RtlUserThreadStart 0x00007ffde32642db
	<unknown> 0x0000000000000000
Breakpoint reached: pool.h:48
list = (snmalloc::Allocator<snmalloc::needs_initialisation, snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20, unsigned char, 0> > >, true> *) 0x17ffc0000
Stack: 
	snmalloc::Pool<snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows> >::acquire<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>&> pool.h:50
	snmalloc::AllocPool<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true> >::acquire globalalloc.h:34
	snmalloc::init_thread_allocator(snmalloc::function_ref<void* (void*)>) threadalloc.h:287
	snmalloc::ThreadAllocCommon::get threadalloc.h:202
	alloc4 first_operation.cc:68
	std::__invoke_impl<void, void (*)(unsigned long long), unsigned long long> invoke.h:60
	std::__invoke<void (*)(unsigned long long), unsigned long long> invoke.h:95
	std::thread::_Invoker<std::tuple<void (*)(unsigned long long), unsigned long long> >::_M_invoke<0ull, 1ull> thread:244
	std::thread::_Invoker<std::tuple<void (*)(unsigned long long), unsigned long long> >::operator() thread:251
	std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)(unsigned long long), unsigned long long> > >::_M_run thread:195
	<unknown> 0x000000006fd42441
	pthread_create_wrapper 0x0000000064945092
	msvcrt!_beginthreadex 0x00007ffde2f3de54
	msvcrt!_endthreadex 0x00007ffde2f3df2c
	KERNEL32!BaseThreadInitThunk 0x00007ffde2118f4e
	ntdll!RtlUserThreadStart 0x00007ffde32642db
	<unknown> 0x0000000000000000
Breakpoint reached: pool.h:48
list = (snmalloc::Allocator<snmalloc::needs_initialisation, snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20, unsigned char, 0> > >, true> *) 0x17ffc4000
Stack: 
	snmalloc::Pool<snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows> >::acquire<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>&> pool.h:50
	snmalloc::AllocPool<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true> >::acquire globalalloc.h:34
	snmalloc::init_thread_allocator(snmalloc::function_ref<void* (void*)>) threadalloc.h:287
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::small_alloc_first_alloc<(snmalloc::ZeroMem)1, (snmalloc::AllowReserve)1> alloc.h:1144
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::small_alloc_rare<(snmalloc::ZeroMem)1, (snmalloc::AllowReserve)1> alloc.h:1133
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::small_alloc_next_free_list<(snmalloc::ZeroMem)1, (snmalloc::AllowReserve)1> alloc.h:1115
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::small_alloc_inner<(snmalloc::ZeroMem)1, (snmalloc::AllowReserve)1> alloc.h:1073
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::small_alloc<(snmalloc::ZeroMem)1, (snmalloc::AllowReserve)1> alloc.h:1046
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::alloc_not_small<(snmalloc::ZeroMem)1, (snmalloc::AllowReserve)1> alloc.h:193
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::alloc<(snmalloc::ZeroMem)1, (snmalloc::AllowReserve)1> alloc.h:183
	calloc1 first_operation.cc:89
	std::__invoke_impl<void, void (*)(unsigned long long), unsigned long long> invoke.h:60
	std::__invoke<void (*)(unsigned long long), unsigned long long> invoke.h:95
	std::thread::_Invoker<std::tuple<void (*)(unsigned long long), unsigned long long> >::_M_invoke<0ull, 1ull> thread:244
	std::thread::_Invoker<std::tuple<void (*)(unsigned long long), unsigned long long> >::operator() thread:251
	std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)(unsigned long long), unsigned long long> > >::_M_run thread:195
	<unknown> 0x000000006fd42441
	pthread_create_wrapper 0x0000000064945092
	msvcrt!_beginthreadex 0x00007ffde2f3de54
	msvcrt!_endthreadex 0x00007ffde2f3df2c
	KERNEL32!BaseThreadInitThunk 0x00007ffde2118f4e
	ntdll!RtlUserThreadStart 0x00007ffde32642db
	<unknown> 0x0000000000000000
Breakpoint reached: pool.h:48
list = (snmalloc::Allocator<snmalloc::needs_initialisation, snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20, unsigned char, 0> > >, true> *) 0x17ffc8000
Stack: 
	snmalloc::Pool<snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows> >::acquire<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>&> pool.h:50
	snmalloc::AllocPool<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true> >::acquire globalalloc.h:34
	snmalloc::init_thread_allocator(snmalloc::function_ref<void* (void*)>) threadalloc.h:287
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::small_alloc_first_alloc<(snmalloc::ZeroMem)1, (snmalloc::AllowReserve)1> alloc.h:1144
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::small_alloc_rare<(snmalloc::ZeroMem)1, (snmalloc::AllowReserve)1> alloc.h:1133
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::small_alloc_next_free_list<(snmalloc::ZeroMem)1, (snmalloc::AllowReserve)1> alloc.h:1115
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::small_alloc_inner<(snmalloc::ZeroMem)1, (snmalloc::AllowReserve)1> alloc.h:1073
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::small_alloc<(snmalloc::ZeroMem)1, (snmalloc::AllowReserve)1> alloc.h:1046
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::alloc_not_small<(snmalloc::ZeroMem)1, (snmalloc::AllowReserve)1> alloc.h:193
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::alloc<(snmalloc::ZeroMem)1, (snmalloc::AllowReserve)1> alloc.h:183
	calloc2 first_operation.cc:98
	std::__invoke_impl<void, void (*)(unsigned long long), unsigned long long> invoke.h:60
	std::__invoke<void (*)(unsigned long long), unsigned long long> invoke.h:95
	std::thread::_Invoker<std::tuple<void (*)(unsigned long long), unsigned long long> >::_M_invoke<0ull, 1ull> thread:244
	std::thread::_Invoker<std::tuple<void (*)(unsigned long long), unsigned long long> >::operator() thread:251
	std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)(unsigned long long), unsigned long long> > >::_M_run thread:195
	<unknown> 0x000000006fd42441
	pthread_create_wrapper 0x0000000064945092
	msvcrt!_beginthreadex 0x00007ffde2f3de54
	msvcrt!_endthreadex 0x00007ffde2f3df2c
	KERNEL32!BaseThreadInitThunk 0x00007ffde2118f4e
	ntdll!RtlUserThreadStart 0x00007ffde32642db
	<unknown> 0x0000000000000000
Breakpoint reached: pool.h:48
list = (snmalloc::Allocator<snmalloc::needs_initialisation, snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20, unsigned char, 0> > >, true> *) 0x17ffc8000
Stack: 
	snmalloc::Pool<snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows> >::acquire<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>&> pool.h:50
	snmalloc::AllocPool<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true> >::acquire globalalloc.h:34
	f first_operation.cc:151
	main first_operation.cc:189
	__tmainCRTStartup 0x00000000004013b4
	mainCRTStartup 0x000000000040150b
Breakpoint reached: pool.h:48
list = (snmalloc::Allocator<snmalloc::needs_initialisation, snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20, unsigned char, 0> > >, true> *) 0x17ffd0000
Stack: 
	snmalloc::Pool<snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows> >::acquire<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>&> pool.h:50
	snmalloc::AllocPool<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true> >::acquire globalalloc.h:34
	snmalloc::init_thread_allocator(snmalloc::function_ref<void* (void*)>) threadalloc.h:287
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::small_alloc_first_alloc<(snmalloc::ZeroMem)1, (snmalloc::AllowReserve)1> alloc.h:1144
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::small_alloc_rare<(snmalloc::ZeroMem)1, (snmalloc::AllowReserve)1> alloc.h:1133
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::small_alloc_next_free_list<(snmalloc::ZeroMem)1, (snmalloc::AllowReserve)1> alloc.h:1115
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::small_alloc_inner<(snmalloc::ZeroMem)1, (snmalloc::AllowReserve)1> alloc.h:1073
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::small_alloc<(snmalloc::ZeroMem)1, (snmalloc::AllowReserve)1> alloc.h:1046
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::alloc_not_small<(snmalloc::ZeroMem)1, (snmalloc::AllowReserve)1> alloc.h:193
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::alloc<(snmalloc::ZeroMem)1, (snmalloc::AllowReserve)1> alloc.h:183
	calloc3 first_operation.cc:106
	std::__invoke_impl<void, void (*)(unsigned long long), unsigned long long> invoke.h:60
	std::__invoke<void (*)(unsigned long long), unsigned long long> invoke.h:95
	std::thread::_Invoker<std::tuple<void (*)(unsigned long long), unsigned long long> >::_M_invoke<0ull, 1ull> thread:244
	std::thread::_Invoker<std::tuple<void (*)(unsigned long long), unsigned long long> >::operator() thread:251
	std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)(unsigned long long), unsigned long long> > >::_M_run thread:195
	<unknown> 0x000000006fd42441
	pthread_create_wrapper 0x0000000064945092
	msvcrt!_beginthreadex 0x00007ffde2f3de54
	msvcrt!_endthreadex 0x00007ffde2f3df2c
	KERNEL32!BaseThreadInitThunk 0x00007ffde2118f4e
	ntdll!RtlUserThreadStart 0x00007ffde32642db
	<unknown> 0x0000000000000000
Breakpoint reached: pool.h:48
list = (snmalloc::Allocator<snmalloc::needs_initialisation, snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20, unsigned char, 0> > >, true> *) 0x17ffd4000
Stack: 
	snmalloc::Pool<snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows> >::acquire<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>&> pool.h:50
	snmalloc::AllocPool<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true> >::acquire globalalloc.h:34
	snmalloc::init_thread_allocator(snmalloc::function_ref<void* (void*)>) threadalloc.h:287
	snmalloc::ThreadAllocCommon::get threadalloc.h:202
	calloc4 first_operation.cc:113
	std::__invoke_impl<void, void (*)(unsigned long long), unsigned long long> invoke.h:60
	std::__invoke<void (*)(unsigned long long), unsigned long long> invoke.h:95
	std::thread::_Invoker<std::tuple<void (*)(unsigned long long), unsigned long long> >::_M_invoke<0ull, 1ull> thread:244
	std::thread::_Invoker<std::tuple<void (*)(unsigned long long), unsigned long long> >::operator() thread:251
	std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)(unsigned long long), unsigned long long> > >::_M_run thread:195
	<unknown> 0x000000006fd42441
	pthread_create_wrapper 0x0000000064945092
	msvcrt!_beginthreadex 0x00007ffde2f3de54
	msvcrt!_endthreadex 0x00007ffde2f3df2c
	KERNEL32!BaseThreadInitThunk 0x00007ffde2118f4e
	ntdll!RtlUserThreadStart 0x00007ffde32642db
	<unknown> 0x0000000000000000
Breakpoint reached: pool.h:48
list = (snmalloc::Allocator<snmalloc::needs_initialisation, snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20, unsigned char, 0> > >, true> *) 0x17ffd8000
Stack: 
	snmalloc::Pool<snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows> >::acquire<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>&> pool.h:50
	snmalloc::AllocPool<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true> >::acquire globalalloc.h:34
	snmalloc::init_thread_allocator(snmalloc::function_ref<void* (void*)>) threadalloc.h:287
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::remote_dealloc_slow alloc.h:1482
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::remote_dealloc alloc.h:1469
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::dealloc alloc.h:298
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::dealloc_sized_slow alloc.h:308
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::dealloc alloc.h:301
	dealloc2 first_operation.cc:126
	std::__invoke_impl<void, void (*)(void*, unsigned long long), void*, unsigned long long> invoke.h:60
	std::__invoke<void (*)(void*, unsigned long long), void*, unsigned long long> invoke.h:95
	std::thread::_Invoker<std::tuple<void (*)(void*, unsigned long long), void*, unsigned long long> >::_M_invoke<0ull, 1ull, 2ull> thread:244
	std::thread::_Invoker<std::tuple<void (*)(void*, unsigned long long), void*, unsigned long long> >::operator() thread:251
	std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)(void*, unsigned long long), void*, unsigned long long> > >::_M_run thread:195
	<unknown> 0x000000006fd42441
	pthread_create_wrapper 0x0000000064945092
	msvcrt!_beginthreadex 0x00007ffde2f3de54
	msvcrt!_endthreadex 0x00007ffde2f3df2c
	KERNEL32!BaseThreadInitThunk 0x00007ffde2118f4e
	ntdll!RtlUserThreadStart 0x00007ffde32642db
	<unknown> 0x0000000000000000
Breakpoint reached: pool.h:48
list = (snmalloc::Allocator<snmalloc::needs_initialisation, snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20, unsigned char, 0> > >, true> *) 0x17ffdc000
Stack: 
	snmalloc::Pool<snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows> >::acquire<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>&> pool.h:50
	snmalloc::AllocPool<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true> >::acquire globalalloc.h:34
	snmalloc::init_thread_allocator(snmalloc::function_ref<void* (void*)>) threadalloc.h:287
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::remote_dealloc_slow alloc.h:1482
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::remote_dealloc alloc.h:1469
	snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>::dealloc alloc.h:352
	dealloc1 first_operation.cc:121
	std::__invoke_impl<void, void (*)(void*, unsigned long long), void*, unsigned long long> invoke.h:60
	std::__invoke<void (*)(void*, unsigned long long), void*, unsigned long long> invoke.h:95
	std::thread::_Invoker<std::tuple<void (*)(void*, unsigned long long), void*, unsigned long long> >::_M_invoke<0ull, 1ull, 2ull> thread:244
	std::thread::_Invoker<std::tuple<void (*)(void*, unsigned long long), void*, unsigned long long> >::operator() thread:251
	std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)(void*, unsigned long long), void*, unsigned long long> > >::_M_run thread:195
	<unknown> 0x000000006fd42441
	pthread_create_wrapper 0x0000000064945092
	msvcrt!_beginthreadex 0x00007ffde2f3de54
	msvcrt!_endthreadex 0x00007ffde2f3df2c
	KERNEL32!BaseThreadInitThunk 0x00007ffde2118f4e
	ntdll!RtlUserThreadStart 0x00007ffde32642db
	<unknown> 0x0000000000000000
Breakpoint reached: pool.h:48
list = (snmalloc::Allocator<snmalloc::needs_initialisation, snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20, unsigned char, 0> > >, true> *) 0x17ff80000
Stack: 
	snmalloc::Pool<snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows> >::acquire<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>&> pool.h:50
	snmalloc::AllocPool<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true> >::acquire globalalloc.h:34
	snmalloc::init_thread_allocator(snmalloc::function_ref<void* (void*)>) threadalloc.h:287
	snmalloc::ThreadAllocCommon::get threadalloc.h:202
	dealloc3 first_operation.cc:131
	std::__invoke_impl<void, void (*)(void*, unsigned long long), void*, unsigned long long> invoke.h:60
	std::__invoke<void (*)(void*, unsigned long long), void*, unsigned long long> invoke.h:95
	std::thread::_Invoker<std::tuple<void (*)(void*, unsigned long long), void*, unsigned long long> >::_M_invoke<0ull, 1ull, 2ull> thread:244
	std::thread::_Invoker<std::tuple<void (*)(void*, unsigned long long), void*, unsigned long long> >::operator() thread:251
	std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)(void*, unsigned long long), void*, unsigned long long> > >::_M_run thread:195
	<unknown> 0x000000006fd42441
	pthread_create_wrapper 0x0000000064945092
	msvcrt!_beginthreadex 0x00007ffde2f3de54
	msvcrt!_endthreadex 0x00007ffde2f3df2c
	KERNEL32!BaseThreadInitThunk 0x00007ffde2118f4e
	ntdll!RtlUserThreadStart 0x00007ffde32642db
	<unknown> 0x0000000000000000
Breakpoint reached: pool.h:48
list = (snmalloc::Allocator<snmalloc::needs_initialisation, snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20, unsigned char, 0> > >, true> *) 0x17ff84000
Stack: 
	snmalloc::Pool<snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows> >::acquire<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>&> pool.h:50
	snmalloc::AllocPool<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true> >::acquire globalalloc.h:34
	snmalloc::init_thread_allocator(snmalloc::function_ref<void* (void*)>) threadalloc.h:287
	snmalloc::ThreadAllocCommon::get threadalloc.h:202
	dealloc4 first_operation.cc:136
	std::__invoke_impl<void, void (*)(void*, unsigned long long), void*, unsigned long long> invoke.h:60
	std::__invoke<void (*)(void*, unsigned long long), void*, unsigned long long> invoke.h:95
	std::thread::_Invoker<std::tuple<void (*)(void*, unsigned long long), void*, unsigned long long> >::_M_invoke<0ull, 1ull, 2ull> thread:244
	std::thread::_Invoker<std::tuple<void (*)(void*, unsigned long long), void*, unsigned long long> >::operator() thread:251
	std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)(void*, unsigned long long), void*, unsigned long long> > >::_M_run thread:195
	<unknown> 0x000000006fd42441
	pthread_create_wrapper 0x0000000064945092
	msvcrt!_beginthreadex 0x00007ffde2f3de54
	msvcrt!_endthreadex 0x00007ffde2f3df2c
	KERNEL32!BaseThreadInitThunk 0x00007ffde2118f4e
	ntdll!RtlUserThreadStart 0x00007ffde32642db
	<unknown> 0x0000000000000000
Breakpoint reached: pool.h:75
list = (snmalloc::Allocator<snmalloc::needs_initialisation, snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20, unsigned char, 0> > >, true> *) 0x17ff88000
Stack: 
	snmalloc::Pool<snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true>, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows> >::release pool.h:80
	snmalloc::AllocPool<snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::Allocator<&snmalloc::needs_initialisation, &snmalloc::init_thread_allocator, snmalloc::MemoryProviderStateMixin<snmalloc::PALWindows>, snmalloc::DefaultChunkMap<snmalloc::GlobalPagemapTemplate<snmalloc::Pagemap<20ull, unsigned char, (unsigned char)0> > >, true> >::release globalalloc.h:39
	f first_operation.cc:174
	main first_operation.cc:189
	__tmainCRTStartup 0x00000000004013b4
	mainCRTStartup 0x000000000040150b
Lazy test!
ERROR: allocator in use.

Process finished with exit code 3

@mjp41
Copy link
Member

mjp41 commented Jun 23, 2020

It is not calling inner_release in the destructor of

static thread_local OnDestruct<ThreadAllocCommon::inner_release> tidier;

This works on other implementations of the CRT. I guess it could be a mingw bug? The only call to release is a direct call.

Has this been failing long? Or has it just started? Can you bisect when it started?

@SchrodingerZhu
Copy link
Contributor Author

SchrodingerZhu commented Jun 23, 2020

test failed since 74657d9, which is really bad because it is the point to add the test.

and debug failed to compile since -rdynamic is added

@SchrodingerZhu
Copy link
Contributor Author

SchrodingerZhu commented Jun 23, 2020

so, according to the current result, it seems that MinGW GCC support is never correct since added?
Sadly, the bug appears on GCC9, GCC10 and clang-10.

@SchrodingerZhu
Copy link
Contributor Author

SchrodingerZhu commented Jun 23, 2020

I get no output with :

#include <iostream>
#include <mutex>
#include <thread>
#include <vector>
static std::mutex lock;

struct DtorTest {
  ~DtorTest(){
	lock.lock();
        std::cout << "dtor called " << std::this_thread::get_id() << std::endl;
        lock.unlock();	
  }
};

void _register() {
	static thread_local DtorTest test {};
}

const size_t TEST = 12;
int main() {
	std::vector<std::thread> threads;
	for (size_t i = 0; i < TEST; ++i) {
		threads.emplace_back(_register);
	}	
	for (auto& i : threads) {
		i.join();
	}
}

@mjp41
Copy link
Member

mjp41 commented Jun 23, 2020

I don't really want to support MinGW as I don't see much demand, and this makes me even less keen. It will lead to memory leaks on MinGW.

Your mini examples works on my machine in WSL with g++/clang++ and Visual studio cl.exe.

@mjp41
Copy link
Member

mjp41 commented Jun 23, 2020

Sadly, the bug appears on GCC9, GCC10 and clang-10.

I assume this is with MinGW?

@SchrodingerZhu
Copy link
Contributor Author

Sadly, the bug appears on GCC9, GCC10 and clang-10.

I assume this is with MinGW?

yes. MinGW's compilers.

@SchrodingerZhu
Copy link
Contributor Author

SchrodingerZhu commented Jun 23, 2020

I am reporting this bug.
MinGW seems to have tons of troubles with thread_local things.
msys2/MINGW-packages#2519 (comment)
It may be a good idea to drop its support if no further progress is made.
I will consider add warnings to my rust crates.
It is sad that linking w/ MinGW is already causing me troubles before. It was a good choice to use mingw with rust because some good IDEs was having poor support w/ the debuggers from MSVC. but everything is improved since then.

@mjp41
Copy link
Member

mjp41 commented Jun 23, 2020

Three year old issues. I am not particularly hopeful it will be fixed.

@mati865
Copy link

mati865 commented Jun 23, 2020

@SchrodingerZhu I believe it's one of many MinGW libgcc issues.
Your code example works better with compiler-rt + libunwind:

$ clang++ mingw.cpp -rtlib=compiler-rt -lunwind && ./a
dtor called 2
dtor called 5
dtor called 4
dtor called 8
dtor called 10
dtor called 6
dtor called 12
dtor called 3
dtor called 11
dtor called 7
dtor called 13
dtor called 9
Windows error: Parameter is incorrect.

@sbabbi
Copy link

sbabbi commented Jun 23, 2020

Hello, I am the guy who reported the issue in mingw.
I had some luck with the following patch ( to winpthread ), but unfortunately at the moment i have no time to follow up.

diff --git a/src/thread.c b/src/thread.c
index 7d18901..2a4c9b8 100644
--- a/src/thread.c
+++ b/src/thread.c
@@ -839,7 +839,7 @@ _pthread_cleanup_dest (pthread_t t)
 		int flag = 0;
 
 		_spin_lite_lock (&tv->spin_keys);
-		for (i = 0; i < tv->keymax; i++)
+		for (i = tv->keymax; i-- > 0; )
 		{
 			void *val = tv->keyval[i];
 

@mjp41
Copy link
Member

mjp41 commented Jun 24, 2020

@mati865 and @sbabbi thanks. I think our issue is slightly different, it __cxa_thread_atexit does not appear to be doing the right thing with regard to the TLS implementation. The things registered with it aren't even called. Thanks both for the suggestions.

@SchrodingerZhu
Copy link
Contributor Author

SchrodingerZhu commented Jun 24, 2020

I got some time tracing the TLS destruction procedure. It seems that those tls_callback and __mingw_cxa_thread_atexit functions are invoked correctly; but there is one thing strange that tls_dtors appear to be optimized out in the distributed binary from MSYS2. Considering the later behavior of the callback functions, I think this optimized-out global variable may lead to some problems here. Indeed, when I step into run_dtor_list. I see GDB jump to some strange address (0x00000000000) and leave a SIGFAULT to me. However, since I do not have a powerful windows PC, I do not have the conditions to test whether it is the true problem to blame.


FYI, tls_dtors is the list of registered dtors. I can see the dtors are pushed to that list, but when the callback executes, the list is broken somehow. It is optimized out in the binary distribution and the call back functions need to use its address.

@mati865
Copy link

mati865 commented Jun 24, 2020

I'm working on fixing MSYS2 libc++. In the meantime you can try using this MinGW toolchain: https://github.com/mstorsjo/llvm-mingw
It doesn't use winpthreads at all so it could help here, I can test it if you provide me instructions.

@SchrodingerZhu
Copy link
Contributor Author

@mjp41 I think @mati865 shows that with compiler-rt the dtors are called correctly but after that an unknown error is thrown. This reproduces on my PC with MinGW, too.


@mati865 I have tried the mcfgthread library by @lhmouse. I think it is also not working here (but maybe I was not using it correctly)? As what I have said in #217 (comment), the problem seems to occur at the crt library (https://github.com/mirror/mingw-w64/blob/944854bca875739814cc466736f8cda5fc9b7f7d/mingw-w64-crt/crt/tls_atexit.c#L38), and this explains why llvm compiler-rt also fails here, because it also uses this part.

@SchrodingerZhu
Copy link
Contributor Author

I think further discussions are not closely related to snmalloc, I have sent this problem to the mailing list; let us just sit back and relax to see what they would suggest.

@mati865
Copy link

mati865 commented Jun 24, 2020

@SchrodingerZhu with llvm-mingw toolchain:

$ export PATH=/opt/llvm-mingw/bin

$ clang++ mingw.cpp && ./a
dtor called 2304
dtor called 21104
dtor called 9228
dtor called 11244
dtor called 9820
dtor called 13688
dtor called 20004
dtor called 20984
dtor called 7612
dtor called 2844
dtor called 7028
dtor called 5000

There is no error.

I think further discussions are not closely related to snmalloc, I have sent this problem to the mailing list; let us just sit back and relax to see what they would suggest.

Sure, thought this info would be useful.

CMakeLists.txt Outdated
@@ -169,7 +169,7 @@ if(NOT DEFINED SNMALLOC_ONLY_HEADER_LIBRARY)
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG")
else()
add_compile_options(-fno-exceptions -fno-rtti -g -ftls-model=initial-exec -fomit-frame-pointer)
if(SNMALLOC_CI_BUILD OR (${CMAKE_BUILD_TYPE} MATCHES "Debug"))
if((SNMALLOC_CI_BUILD OR (${CMAKE_BUILD_TYPE} MATCHES "Debug")) AND NOT MINGW)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of the options in the line above (e.g. the TLS model) also don't look like they make sense on Windows. It looks as if we're conflating Windows and MSVC here a bit and should probably disentangle that a bit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check_cxx_compiler_flag(-rdynamic SNMALLOC_RDYNAMIC)
check_cxx_compiler_flag(-ftls-model=initial-exec SNMALLOC_STATIC_TLS)

is this a better solution?

src/ds/bits.h Outdated
@@ -76,7 +76,7 @@ namespace snmalloc

return BITS - index - 1;
# endif
#elif defined(USE_CLZLL)
#elif defined(USE_BIT_LL)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to use something like this here:

        if constexpr (std::is_same_v<unsigned long, std::size_t>)
        {
                return __builtin_clzl(x);
        }
        else if constexpr (std::is_same_v<unsigned long long, std::size_t>)
        {
                return __builtin_clzll(x);
        }

src/ds/bits.h Outdated
@@ -142,7 +142,9 @@ namespace snmalloc

inline size_t ctz(size_t x)
{
#if __has_builtin(__builtin_ctzl)
#if defined(USE_BIT_LL)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above.

@mjp41
Copy link
Member

mjp41 commented Aug 26, 2020

The ctz issues for MinGW was also affecting clang-cl, so I have done the ctz fix suggested by @davidchisnall in #242.

@SchrodingerZhu
Copy link
Contributor Author

MinGW-w64 seems to have no effective respond to this problem. As other crt (llvm-mingw) do have functioning TLS, maybe we can left this as a patch? I will finally get some time to update and rebase this draft later.

@mati865
Copy link

mati865 commented Aug 27, 2020

Well llvm-mingw is using the same mingw-w64 CRT as MSYS2 and other mingw-w64 based compilers. I think it works with that toolchain because it uses native TLS (GCC uses emutls on Windows and at MSYS2 we had to patch Clang to also do it for compatibility with GCC) and compiler-rt is not affected by the same bug as libgcc (or winpthreads which it uses internally).
So it proves that there is no bug in mingw-w64 itself but within the compiler used together with it.

@SchrodingerZhu
Copy link
Contributor Author

Well llvm-mingw is using the same mingw-w64 CRT as MSYS2 and other mingw-w64 based compilers. I think it works with that toolchain because it uses native TLS (GCC uses emutls on Windows and at MSYS2 we had to patch Clang to also do it for compatibility with GCC) and compiler-rt is not affected by the same bug as libgcc (or winpthreads which it uses internally).
So it proves that there is no bug in mingw-w64 itself but within the compiler used together with it.

isn't it using universal runtime on default?

As this toolchain uses a different CRT and C++ standard library than most mingw toolchains, it is incompatible with object files and static libraries built with other toolchains. Mixing DLLs from other toolchains is supported, but only as long as CRT resources aren't shared across DLL boundaries (no sharing of file handles etc, and memory should be freed by the same DLL that allocated it). (quoted from its README.)

@mati865
Copy link

mati865 commented Aug 27, 2020

@SchrodingerZhu any toolchain can use any CRT library (it's mingw-w64 configuration option) but it does not change anything with regard to TLS bug.

@mjp41
Copy link
Member

mjp41 commented Aug 28, 2020

@mati865

there is no bug in mingw-w64 itself but within the compiler used together with it.

Is there a combination we should recommend for building snmalloc then?

@mati865
Copy link

mati865 commented Aug 28, 2020

@mjp41 I think the safest bet would be saying something like "our testing revealed issues with different mingw-w64 based toolchains, currently https://github.com/mstorsjo/llvm-mingw is the only toolchain known to work properly".
I can try to dedicate some time next week to test various combinations but cannot promise anything.

@SchrodingerZhu
Copy link
Contributor Author

@mati865 would you help test whether the current PR is working (passing all the tests) under llvm-mingw? or perhaps I can open a VM for it later.

@mati865
Copy link

mati865 commented Sep 19, 2020

@SchrodingerZhu I had to make this change to avoid error on MinGW:

diff --git a/src/test/func/malloc/malloc.cc b/src/test/func/malloc/malloc.cc
index 1d54525..9fe591a 100644
--- a/src/test/func/malloc/malloc.cc
+++ b/src/test/func/malloc/malloc.cc
@@ -4,7 +4,7 @@
 #define SNMALLOC_NAME_MANGLE(a) our_##a
 #include "../../../override/malloc.cc"

-#if defined(_WIN32) && !defined(_MSC_VER)
+#if defined(_WIN32) && defined(_MSC_VER)
 #  define ST_FMT "I"
 #else
 #  define ST_FMT "z"

After that with GCC based MinGW those tests fail:

The following tests FAILED:
         16 - func-first_operation-1 (Failed)
         17 - func-first_operation-16 (Failed)
         18 - func-first_operation-oe (Failed)

With llvm-mingw everything passes.

@mati865
Copy link

mati865 commented Nov 24, 2021

FWIW MSYS2 now ships more environments: https://www.msys2.org/docs/environments/
In short UCRT64 is the same as MINGW64 except CRT library being UCRT and CLANG64 is similar to llvm-mingw mentioned earlier in this thread.

@mjp41
Copy link
Member

mjp41 commented Dec 15, 2021

@SchrodingerZhu the new setting here:
https://github.com/microsoft/snmalloc/blob/main/CMakeLists.txt#L32
might unlock the issues on MinGW

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

Successfully merging this pull request may close these issues.

None yet

5 participants