Skip to content

Commit ef183e9

Browse files
Revert "Fix lookup for current Thread in async signal handler" (#122415)
Just want to run native AOT outerloop on this. Reverts #122048
1 parent 3e795e8 commit ef183e9

File tree

14 files changed

+55
-328
lines changed

14 files changed

+55
-328
lines changed

src/coreclr/nativeaot/Runtime/CMakeLists.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,6 @@ set(COMMON_RUNTIME_SOURCES
5555
${CLR_SRC_NATIVE_DIR}/minipal/xoshiro128pp.c
5656
)
5757

58-
if (CLR_CMAKE_TARGET_UNIX AND NOT CLR_CMAKE_TARGET_ARCH_WASM)
59-
list(APPEND COMMON_RUNTIME_SOURCES
60-
${RUNTIME_DIR}/asyncsafethreadmap.cpp
61-
)
62-
endif()
63-
6458
set(SERVER_GC_SOURCES
6559
${GC_DIR}/gceesvr.cpp
6660
${GC_DIR}/gcsvr.cpp

src/coreclr/nativeaot/Runtime/threadstore.cpp

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
#include "TargetPtrs.h"
2323
#include "yieldprocessornormalized.h"
2424
#include <minipal/time.h>
25-
#include <minipal/thread.h>
26-
#include "asyncsafethreadmap.h"
2725

2826
#include "slist.inl"
2927

@@ -145,14 +143,6 @@ void ThreadStore::AttachCurrentThread(bool fAcquireThreadStoreLock)
145143
pAttachingThread->m_ThreadStateFlags = Thread::TSF_Attached;
146144

147145
pTS->m_ThreadList.PushHead(pAttachingThread);
148-
149-
#if defined(TARGET_UNIX) && !defined(TARGET_WASM)
150-
if (!InsertThreadIntoAsyncSafeMap(pAttachingThread->m_threadId, pAttachingThread))
151-
{
152-
PalPrintFatalError("\nFailed to insert thread into async-safe map due to out of memory.\n");
153-
RhFailFast();
154-
}
155-
#endif // TARGET_UNIX && !TARGET_WASM
156146
}
157147

158148
// static
@@ -198,9 +188,6 @@ void ThreadStore::DetachCurrentThread()
198188
pTS->m_ThreadList.RemoveFirst(pDetachingThread);
199189
// tidy up GC related stuff (release allocation context, etc..)
200190
pDetachingThread->Detach();
201-
#if defined(TARGET_UNIX) && !defined(TARGET_WASM)
202-
RemoveThreadFromAsyncSafeMap(pDetachingThread->m_threadId, pDetachingThread);
203-
#endif
204191
}
205192

206193
// post-mortem clean up.
@@ -365,13 +352,6 @@ EXTERN_C RuntimeThreadLocals* RhpGetThread()
365352
return &tls_CurrentThread;
366353
}
367354

368-
#if defined(TARGET_UNIX) && !defined(TARGET_WASM)
369-
Thread * ThreadStore::GetCurrentThreadIfAvailableAsyncSafe()
370-
{
371-
return (Thread*)FindThreadInAsyncSafeMap(minipal_get_current_thread_id_no_cache());
372-
}
373-
#endif // TARGET_UNIX && !TARGET_WASM
374-
375355
#endif // !DACCESS_COMPILE
376356

377357
#ifdef _WIN32

src/coreclr/nativeaot/Runtime/threadstore.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ class ThreadStore
4747
static Thread * RawGetCurrentThread();
4848
static Thread * GetCurrentThread();
4949
static Thread * GetCurrentThreadIfAvailable();
50-
static Thread * GetCurrentThreadIfAvailableAsyncSafe();
5150
static PTR_Thread GetSuspendingThread();
5251
static void AttachCurrentThread();
5352
static void AttachCurrentThread(bool fAcquireThreadStoreLock);

src/coreclr/nativeaot/Runtime/unix/PalUnix.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,24 +1017,24 @@ static struct sigaction g_previousActivationHandler;
10171017

10181018
static void ActivationHandler(int code, siginfo_t* siginfo, void* context)
10191019
{
1020-
Thread* pThread = ThreadStore::GetCurrentThreadIfAvailableAsyncSafe();
1021-
if (pThread)
1022-
{
1023-
// Only accept activations from the current process
1024-
if (siginfo->si_pid == getpid()
1020+
// Only accept activations from the current process
1021+
if (siginfo->si_pid == getpid()
10251022
#ifdef HOST_APPLE
1026-
// On Apple platforms si_pid is sometimes 0. It was confirmed by Apple to be expected, as the si_pid is tracked at the process level. So when multiple
1027-
// signals are in flight in the same process at the same time, it may be overwritten / zeroed.
1028-
|| siginfo->si_pid == 0
1023+
// On Apple platforms si_pid is sometimes 0. It was confirmed by Apple to be expected, as the si_pid is tracked at the process level. So when multiple
1024+
// signals are in flight in the same process at the same time, it may be overwritten / zeroed.
1025+
|| siginfo->si_pid == 0
10291026
#endif
1030-
)
1031-
{
1032-
// Make sure that errno is not modified
1033-
int savedErrNo = errno;
1034-
Thread::HijackCallback((NATIVE_CONTEXT*)context, pThread);
1035-
errno = savedErrNo;
1036-
}
1027+
)
1028+
{
1029+
// Make sure that errno is not modified
1030+
int savedErrNo = errno;
1031+
Thread::HijackCallback((NATIVE_CONTEXT*)context, NULL);
1032+
errno = savedErrNo;
1033+
}
10371034

1035+
Thread* pThread = ThreadStore::GetCurrentThreadIfAvailable();
1036+
if (pThread)
1037+
{
10381038
pThread->SetActivationPending(false);
10391039
}
10401040

src/coreclr/pal/src/exception/signal.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -936,20 +936,22 @@ static void inject_activation_handler(int code, siginfo_t *siginfo, void *contex
936936
CONTEXTToNativeContext(&winContext, ucontext);
937937
}
938938
}
939-
940-
// Call the original handler when it is not ignored or default (terminate).
941-
if (g_previous_activation.sa_flags & SA_SIGINFO)
942-
{
943-
_ASSERTE(g_previous_activation.sa_sigaction != NULL);
944-
g_previous_activation.sa_sigaction(code, siginfo, context);
945-
}
946939
else
947940
{
948-
if (g_previous_activation.sa_handler != SIG_IGN &&
949-
g_previous_activation.sa_handler != SIG_DFL)
941+
// Call the original handler when it is not ignored or default (terminate).
942+
if (g_previous_activation.sa_flags & SA_SIGINFO)
943+
{
944+
_ASSERTE(g_previous_activation.sa_sigaction != NULL);
945+
g_previous_activation.sa_sigaction(code, siginfo, context);
946+
}
947+
else
950948
{
951-
_ASSERTE(g_previous_activation.sa_handler != NULL);
952-
g_previous_activation.sa_handler(code);
949+
if (g_previous_activation.sa_handler != SIG_IGN &&
950+
g_previous_activation.sa_handler != SIG_DFL)
951+
{
952+
_ASSERTE(g_previous_activation.sa_handler != NULL);
953+
g_previous_activation.sa_handler(code);
954+
}
953955
}
954956
}
955957
}

src/coreclr/runtime/asyncsafethreadmap.cpp

Lines changed: 0 additions & 126 deletions
This file was deleted.

src/coreclr/runtime/asyncsafethreadmap.h

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/coreclr/vm/CMakeLists.txt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -379,12 +379,6 @@ set(VM_SOURCES_WKS
379379
${VM_SOURCES_GDBJIT}
380380
)
381381

382-
if (CLR_CMAKE_TARGET_UNIX AND NOT CLR_CMAKE_TARGET_ARCH_WASM)
383-
list(APPEND VM_SOURCES_WKS
384-
${RUNTIME_DIR}/asyncsafethreadmap.cpp
385-
)
386-
endif()
387-
388382
# coreclr needs to compile codeman.cpp differently depending on flavor (i.e. dll vs. static lib))
389383
list(REMOVE_ITEM VM_SOURCES_WKS codeman.cpp)
390384

@@ -480,12 +474,6 @@ set(VM_HEADERS_WKS
480474
${VM_HEADERS_GDBJIT}
481475
)
482476

483-
if (CLR_CMAKE_TARGET_UNIX AND NOT CLR_CMAKE_TARGET_ARCH_WASM)
484-
list(APPEND VM_HEADERS_WKS
485-
${RUNTIME_DIR}/asyncsafethreadmap.h
486-
)
487-
endif()
488-
489477
set(GC_SOURCES_WKS
490478
${GC_SOURCES_DAC_AND_WKS_COMMON}
491479
../gc/gceventstatus.cpp

src/coreclr/vm/codeman.cpp

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ IJitManager::IJitManager()
861861
// been stopped when we suspend the EE so they won't be touching an element that is about to be deleted.
862862
// However for pre-emptive mode threads, they could be stalled right on top of the element we want
863863
// to delete, so we need to apply the reader lock to them and wait for them to drain.
864-
ExecutionManager::ScanFlag ExecutionManager::GetScanFlags(Thread *pThread)
864+
ExecutionManager::ScanFlag ExecutionManager::GetScanFlags()
865865
{
866866
CONTRACTL {
867867
NOTHROW;
@@ -872,10 +872,7 @@ ExecutionManager::ScanFlag ExecutionManager::GetScanFlags(Thread *pThread)
872872
#if !defined(DACCESS_COMPILE)
873873

874874

875-
if (!pThread)
876-
{
877-
pThread = GetThreadNULLOk();
878-
}
875+
Thread *pThread = GetThreadNULLOk();
879876

880877
if (!pThread)
881878
return ScanNoReaderLock;
@@ -5243,24 +5240,6 @@ BOOL ExecutionManager::IsManagedCode(PCODE currentPC)
52435240
return IsManagedCodeWorker(currentPC, &lockState);
52445241
}
52455242

5246-
//**************************************************************************
5247-
BOOL ExecutionManager::IsManagedCodeNoLock(PCODE currentPC)
5248-
{
5249-
CONTRACTL {
5250-
NOTHROW;
5251-
GC_NOTRIGGER;
5252-
} CONTRACTL_END;
5253-
5254-
if (currentPC == (PCODE)NULL)
5255-
return FALSE;
5256-
5257-
_ASSERTE(GetScanFlags() != ScanReaderLock);
5258-
5259-
// Since ScanReaderLock is not set, then we must assume that the ReaderLock is effectively taken.
5260-
RangeSectionLockState lockState = RangeSectionLockState::ReaderLocked;
5261-
return IsManagedCodeWorker(currentPC, &lockState);
5262-
}
5263-
52645243
//**************************************************************************
52655244
NOINLINE // Make sure that the slow path with lock won't affect the fast path
52665245
BOOL ExecutionManager::IsManagedCodeWithLock(PCODE currentPC)

src/coreclr/vm/codeman.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2299,15 +2299,11 @@ class ExecutionManager
22992299
};
23002300

23012301
// Returns default scan flag for current thread
2302-
static ScanFlag GetScanFlags(Thread *pThread = NULL);
2302+
static ScanFlag GetScanFlags();
23032303

23042304
// Returns whether currentPC is in managed code. Returns false for jump stubs on WIN64.
23052305
static BOOL IsManagedCode(PCODE currentPC);
23062306

2307-
// Returns whether currentPC is in managed code. Returns false for jump stubs on WIN64.
2308-
// Does not acquire the reader lock. Caller must ensure it is safe.
2309-
static BOOL IsManagedCodeNoLock(PCODE currentPC);
2310-
23112307
// Returns true if currentPC is ready to run codegen
23122308
static BOOL IsReadyToRunCode(PCODE currentPC);
23132309

0 commit comments

Comments
 (0)