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

Crashing on launch #73

Open
JohnJScott opened this issue Sep 26, 2022 · 1 comment
Open

Crashing on launch #73

JohnJScott opened this issue Sep 26, 2022 · 1 comment

Comments

@JohnJScott
Copy link

I compiled Hoard with Visual Studio 2022 NMake - the only required change was:

void * __attribute__((flatten)) xxmalloc (size_t sz) __attribute__((alloc_size(1))) __attribute((malloc))
to
void * [[forceinline]] xxmalloc (size_t sz)

(more on this later). However, after linking with my exe, there is a crash while trying to initialize the heap (?)

 	ntdll.dll!RtlReportCriticalFailure�()	Unknown
 	ntdll.dll!RtlpHeapHandleError�()	Unknown
 	ntdll.dll!RtlpHpHeapHandleError�()	Unknown
 	ntdll.dll!RtlpLogHeapFailure�()	Unknown
 	ntdll.dll!RtlSizeHeap()	Unknown
 	ucrtbase.dll!_recalloc_base()	Unknown
 	ucrtbase.dll!<lambda>(void)()	Unknown
 	ucrtbase.dll!__crt_seh_guarded_call<int>::operator()<<lambda_638799b9deba96c50f710eeac98168cd>,<lambda>(void) &,<lambda_a6f7d7db0129f75315ebf26d50c089f1>>()	Unknown
 	ucrtbase.dll!_register_onexit_function�()	Unknown
>	GPEGEncoder.exe!_onexit(int(*)() function) Line 261	C++
 	GPEGEncoder.exe!atexit(void(*)() function) Line 275	C++
 	ucrtbase.dll!_initterm�()	Unknown
 	GPEGEncoder.exe!__scrt_common_main_seh() Line 258	C++
 	kernel32.dll!BaseThreadInitThunk�()	Unknown
 	ntdll.dll!RtlUserThreadStart�()	Unknown

I will try to track this down some more, but do you have any tips in the meantime?

It's a single exe compiled with Visual Studio 2022 Community (the free version) to the C++20 standard - could that be the issue?

Speaking on C++20, [[forceinline]] is part of that standard - and I think [[msvc::forceinline]] is part of the C++17 standard - with the current compile it's just ignored.

Also, the array of Patch class doesn't compile in Heap-Layers in C++20 - there needs to be a nullptr added for the original FARPROC. Old C++ compilation automatically casted the bool to a nullptr, but C++20 doesn't allow that.

If Hoard does what it says on the tin and mitigates allocation locks in multithreaded code, I'm very excited to get this to work!

I can help fix up these issues and give a PR if you like, but I need to get it to work first.

Cheers
John

@JohnJScott
Copy link
Author

The variables are:
  | function | 0x00007ff79b0d03f0 {GPEGEncoder.exe!dynamic atexit destructor for 'MobilityStrings''(void)} | int(*)()`

MobilityStrings are:

static const Primal::map<EMobility, std::string> MobilityStrings
{
	{ EMobility::Unknown, "Unknown" },

	{ EMobility::Static, "Static" },
	{ EMobility::Stationary, "Stationary" },
	{ EMobility::Movable, "Movable" }
};

This only shows up when I call a function in a library. I have a thin exe that calls functions in a static lib - it's done this way so unit tests can call the same functions. Anyway, attempts to repro this in a HelloWorld style app have so far failed.

Cheers
John

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

1 participant