Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
Port fixes for CoreCLR #5837, 6016 and 6460
Browse files Browse the repository at this point in the history
  • Loading branch information
gkhanna79 committed Aug 4, 2016
1 parent abbb8f6 commit e4d5001
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 8 deletions.
31 changes: 27 additions & 4 deletions src/jit/ee_il_dll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,33 @@ void __stdcall jitStartup(ICorJitHost* jitHost)
#else
if (jitstdout == nullptr)
{
int jitstdoutFd = _dup(_fileno(procstdout()));
_setmode(jitstdoutFd, _O_TEXT);
jitstdout = _fdopen(jitstdoutFd, "w");
assert(jitstdout != nullptr);
int stdoutFd = _fileno(procstdout());
// Check fileno error output(s) -1 may overlap with errno result
// but is included for completness.
// We want to detect the case where the initial handle is null
// or bogus and avoid making further calls.
if ((stdoutFd != -1) && (stdoutFd != -2) && (errno != EINVAL))
{
int jitstdoutFd = _dup(_fileno(procstdout()));
// Check the error status returned by dup.
if (jitstdoutFd != -1)
{
_setmode(jitstdoutFd, _O_TEXT);
jitstdout = _fdopen(jitstdoutFd, "w");
assert(jitstdout != nullptr);

// Prevent the FILE* from buffering its output in order to avoid calls to
// `fflush()` throughout the code.
setvbuf(jitstdout, nullptr, _IONBF, 0);
}
}
}

// If jitstdout is still null, fallback to whatever procstdout() was
// initially set to.
if (jitstdout == nullptr)
{
jitstdout = procstdout();
}
#endif

Expand Down
6 changes: 3 additions & 3 deletions src/pal/src/exception/signal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,10 +464,10 @@ static void inject_activation_handler(int code, siginfo_t *siginfo, void *contex
if (g_safeActivationCheckFunction(CONTEXTGetPC(&winContext), /* checkingCurrentThread */ TRUE))
{
g_activationFunction(&winContext);
}

// Activation function may have modified the context, so update it.
CONTEXTToNativeContext(&winContext, ucontext);
// Activation function may have modified the context, so update it.
CONTEXTToNativeContext(&winContext, ucontext);
}
}
else if (g_previous_activation.sa_sigaction != NULL)
{
Expand Down
2 changes: 1 addition & 1 deletion src/pal/src/include/pal/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ typedef ucontext_t native_context_t;
#define MCREG_Rax(mc) ((mc).gregs[REG_RAX])
#define MCREG_Rip(mc) ((mc).gregs[REG_RIP])
#define MCREG_Rsp(mc) ((mc).gregs[REG_RSP])
#define MCREG_SegCs(mc) ((mc).gregs[REG_CSGSFS])
#define MCREG_SegCs(mc) (*(WORD*)&((mc).gregs[REG_CSGSFS]))
#define MCREG_R8(mc) ((mc).gregs[REG_R8])
#define MCREG_R9(mc) ((mc).gregs[REG_R9])
#define MCREG_R10(mc) ((mc).gregs[REG_R10])
Expand Down
4 changes: 4 additions & 0 deletions src/vm/appdomain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14322,6 +14322,10 @@ HRESULT RuntimeInvokeHostAssemblyResolver(INT_PTR pManagedAssemblyLoadContextToB

// Make the call
_gcRefs.oRefLoadedAssembly = (ASSEMBLYREF) methLoadAssembly.Call_RetOBJECTREF(args);
if (_gcRefs.oRefLoadedAssembly != NULL)
{
fResolvedAssembly = true;
}
}

if (fResolvedAssembly && !fResolvedAssemblyViaTPALoadContext)
Expand Down

0 comments on commit e4d5001

Please sign in to comment.