Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/coreclr/debug/crashreport/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ set(CRASHREPORT_SOURCES
inproccrashreportwatchdog.cpp
)

include(configure.cmake)

include_directories(${CMAKE_CURRENT_BINARY_DIR})
add_library(inproccrashreport OBJECT ${CRASHREPORT_SOURCES})
target_include_directories(inproccrashreport PRIVATE ${CLR_DIR}/pal/src/include)

Expand Down
7 changes: 7 additions & 0 deletions src/coreclr/debug/crashreport/config.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#pragma once

#cmakedefine01 HAVE_POLL
#cmakedefine01 HAVE_UCONTEXT_H
4 changes: 4 additions & 0 deletions src/coreclr/debug/crashreport/configure.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
check_function_exists(poll HAVE_POLL)
check_include_files(ucontext.h HAVE_UCONTEXT_H)

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
1 change: 1 addition & 0 deletions src/coreclr/debug/crashreport/inproccrashreporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include "pal.h"
#include "volatile.h"
#include "config.h"

#include <fcntl.h>
#include <errno.h>
Expand Down
3 changes: 2 additions & 1 deletion src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10507,7 +10507,8 @@ GenTree* Compiler::gtNewLoadValueNode(var_types type, ClassLayout* layout, GenTr
{
unsigned lclNum = addr->AsLclFld()->GetLclNum();
LclVarDsc* varDsc = lvaGetDesc(lclNum);
if ((varDsc->TypeGet() == type) && ((type != TYP_STRUCT) || layout->CanAssignFrom(varDsc->GetLayout())))
if ((varDsc->TypeGet() == type) &&
((type != TYP_STRUCT) || (layout != nullptr && layout->CanAssignFrom(varDsc->GetLayout()))))
Comment on lines 10509 to +10511

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

@jakobbotsch, illumos gcc thinks that it can be null here from the path followed by gtNewLoadValueNode(JITtype2varType(constraintTyp), nullptr, obj); (as JITtype2varType can return non TYP_STRUCT type). I think error was seen with release config only given the assert at the start of this method, but not sure.

{
return gtNewLclvNode(lclNum, type);
}
Expand Down
21 changes: 18 additions & 3 deletions src/native/corehost/hostmisc/pal.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ typedef wchar_t pal_char_t;
// C++ mode: MSVC's default (non-conforming) preprocessor leaves L##__FUNCTION__
// unexpanded so that it evaluates to MSVC's wide function-name literal. Using a
// two-step helper here would force argument expansion and break that.
#define _X(s) L ## s
#define PAL_X(s) L ## s
#else
// C mode: MSVC's /std:c11 conforming preprocessor (and other conforming
// compilers) suppress argument expansion before ##. A two-step helper forces
// the argument to be expanded first so e.g. _X(HOST_VERSION) yields a wide
// string literal rather than the identifier LHOST_VERSION.
#define _X_HELPER(s) L ## s
#define _X(s) _X_HELPER(s)
#define PAL_X(s) _X_HELPER(s)
#endif
#else // !_WIN32
typedef char pal_char_t;
#define _X(s) s
#define PAL_X(s) s
#endif // _WIN32

// Max path buffer for apphost string operations
Expand Down Expand Up @@ -122,6 +122,21 @@ typedef void* pal_proc_t;

#include "configure.h"

#if defined(TARGET_SUNOS)
// Ensure character traits have been processed safely before we intercept the identifier
#if defined(__cplusplus)
#include <locale>
#include <cctype>
#else
#include <ctype.h>
#endif

// Wipe the system bitmask and instantly route it to your project's PAL_X layout
#undef _X
#endif

#define _X(s) PAL_X(s)

// Wide-stringify the value of a macro: _STRINGIFY(FOO) -> _X("<expanded value of FOO>").
#define _STRINGIFY(s) _X(s)

Expand Down
15 changes: 9 additions & 6 deletions src/native/corehost/hostmisc/pal.unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ bool pal_readdir_onlydirectories(const pal_char_t* path, pal_readdir_callback_t
#if HAVE_DIRENT_D_TYPE
int entry_type = entry->d_type;
#else
#define DT_UNKNOWN 0
#define DT_DIR 4
#define DT_REG 8
#define DT_LNK 10
int entry_type = DT_UNKNOWN;
#endif

Expand Down Expand Up @@ -357,11 +361,6 @@ bool pal_utf8_to_palstr(const char* utf8, pal_char_t* out, size_t out_len)
return true;
}

// Two-level stringize so PATH_MAX's value (not its name) can be used as an
// explicit sscanf field width below.
#define PROC_MAPS_STR2(x) #x
#define PROC_MAPS_STR(x) PROC_MAPS_STR2(x)

// dlopen on some systems only finds a loaded library when given its full path.
// As a fallback, scan /proc/self/maps for a mapped file whose name contains
// library_name. On success sets *dll and *out_path (heap-allocated, caller
Expand All @@ -378,8 +377,12 @@ static bool get_loaded_library_from_proc_maps(const pal_char_t* library_name, pa
char found_path[PATH_MAX + 1];
while (getline(&line, &line_cap, file) != -1)
{
// Build the sscanf format dynamically to safely handle parenthesized PATH_MAX values on some platforms (like Haiku)
char fmt[64];
snprintf(fmt, sizeof(fmt), "%%*p-%%*p %%*[-rwxsp] %%*p %%*[:0-9a-f] %%*d %%%ds\n", PATH_MAX);

char buf[PATH_MAX + 1]; // + 1 for the NUL terminator
if (sscanf(line, "%*p-%*p %*[-rwxsp] %*p %*[:0-9a-f] %*d %" PROC_MAPS_STR(PATH_MAX) "s\n", buf) == 1)
if (sscanf(line, fmt, buf) == 1)
{
const char* last_sep = strrchr(buf, DIR_SEPARATOR);
if (last_sep == NULL)
Expand Down
4 changes: 2 additions & 2 deletions src/native/libs/System.Native/pal_networkstatistics.c
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ int32_t SystemNative_GetActiveUdpListeners(IPEndPointInfo* infos, int32_t* infoC
// route/interface sysctl APIs (rt_msghdr), not the protocol statistics that live in tcp_var.h.
// Gate them on HAVE_RT_MSGHDR so platforms that lack tcp_var.h but do have rt_msghdr (e.g. OpenBSD)
// still get the real implementation instead of the ENOTSUP stub.
#if HAVE_RT_MSGHDR
#if HAVE_RT_MSGHDR && HAVE_SYS_SYSCTL_H
#include <string.h>
#include <assert.h>
#include <sys/types.h>
Expand Down Expand Up @@ -858,4 +858,4 @@ int32_t SystemNative_GetNumRoutes(void)
errno = ENOTSUP;
return -1;
}
#endif // HAVE_RT_MSGHDR
#endif // HAVE_RT_MSGHDR && HAVE_SYS_SYSCTL_H
9 changes: 9 additions & 0 deletions src/native/minipal/ospagesize.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@

uint32_t minipal_getpagesize(void)
{
#if defined(TARGET_HAIKU) && defined(__clang__)
static _Atomic uint32_t cached_page_size = 0;
uint32_t page_size = __c11_atomic_load(&cached_page_size, memory_order_relaxed);
#else
static atomic_uint cached_page_size = 0;
uint32_t page_size = atomic_load_explicit(&cached_page_size, memory_order_relaxed);
#endif
if (page_size == 0)
{
long sc = sysconf(_SC_PAGESIZE);
Expand All @@ -25,7 +30,11 @@ uint32_t minipal_getpagesize(void)
abort();
}
page_size = (uint32_t)sc;
#if defined(TARGET_HAIKU) && defined(__clang__)
__c11_atomic_store(&cached_page_size, page_size, memory_order_relaxed);
#else
atomic_store_explicit(&cached_page_size, page_size, memory_order_relaxed);
#endif
}
return page_size;
}
Loading