Skip to content

Commit

Permalink
Remove erroneous function cast (#14673)
Browse files Browse the repository at this point in the history
### Description
The custom thread entry point was declared `__stdcall` even though the
API dictated a different type. Casting caused improper cleanup of the
stack and crash manifested only in 32-bit Debug builds.

### Motivation and Context
This addresses #14613
  • Loading branch information
yuslepukhin authored Feb 14, 2023
1 parent 2a4c9a5 commit 6eeeecf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions onnxruntime/core/platform/windows/env.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class WindowsThread : public EnvThread {
}

if (custom_create_thread_fn) {
custom_thread_handle = custom_create_thread_fn(custom_thread_creation_options, (OrtThreadWorkerFn)CustomThreadMain, local_param.get());
custom_thread_handle = custom_create_thread_fn(custom_thread_creation_options, CustomThreadMain, local_param.get());
if (!custom_thread_handle) {
ORT_THROW("custom_create_thread_fn returned invalid handle.");
}
Expand Down Expand Up @@ -217,7 +217,7 @@ class WindowsThread : public EnvThread {
}
#pragma warning(pop)

static void __stdcall CustomThreadMain(void* param) {
static void CustomThreadMain(void* param) {
std::unique_ptr<Param> p(static_cast<Param*>(param));
ORT_TRY {
p->start_address(p->index, p->param);
Expand Down

0 comments on commit 6eeeecf

Please sign in to comment.