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

Fix gcc warnings during mono linux-x64 build #60675

Merged
merged 4 commits into from
Nov 2, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion src/coreclr/pal/src/thread/process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2148,7 +2148,7 @@ GetProcessIdDisambiguationKey(DWORD processId, UINT64 *disambiguationKey)

// All the format specifiers for the fields in the stat file are provided by 'man proc'.
int sscanfRet = sscanf_s(scanStartPosition,
"%*c %*d %*d %*d %*d %*d %*u %*lu %*lu %*lu %*lu %*lu %*lu %*ld %*ld %*ld %*ld %*ld %*ld %llu \n",
"%*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %*u %*u %*u %*d %*d %*d %*d %*d %*d %llu \n",
&starttime);

if (sscanfRet != 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ static UChar* s_breakIteratorRules = NULL;
// We are customizing the break iterator to exclude the CRxLF rule which don't allow breaking between CR and LF.
// The general rules syntax explained in the doc https://unicode-org.github.io/icu/userguide/boundaryanalysis/break-rules.html.
// The ICU latest rules definition exist here https://github.com/unicode-org/icu/blob/main/icu4c/source/data/brkitr/rules/char.txt.
static UBreakIterator* CreateCustomizedBreakIterator()
static UBreakIterator* CreateCustomizedBreakIterator(void)
{
static UChar emptyString[1];
UBreakIterator* breaker;
Expand Down Expand Up @@ -815,6 +815,7 @@ static int32_t GetSearchIteratorUsingCollator(
if (!U_SUCCESS(err))
{
int32_t r;
(void)r;
r = RestoreSearchHandle(pSortHandle, *pSearchIterator, options);
assert(r && "restoring search handle shouldn't fail.");
return -1;
Expand All @@ -824,6 +825,7 @@ static int32_t GetSearchIteratorUsingCollator(
if (!U_SUCCESS(err))
{
int32_t r;
(void)r;
r = RestoreSearchHandle(pSortHandle, *pSearchIterator, options);
assert(r && "restoring search handle shouldn't fail.");
return -1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ static int FindICULibs(const char* versionPrefix, char* symbolName, char* symbol

#endif

static void ValidateICUDataCanLoad()
static void ValidateICUDataCanLoad(void)
{
UVersionInfo version;
UErrorCode err = U_ZERO_ERROR;
Expand Down
5 changes: 2 additions & 3 deletions src/mono/cmake/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -510,9 +510,6 @@
/* Define to 1 if you have the `strerror_r' function. */
#cmakedefine HAVE_STRERROR_R 1

/* Define to 1 if strerror_r returns char *. */
#cmakedefine STRERROR_R_CHAR_P 1

/* Have GLIBC_BEFORE_2_3_4_SCHED_SETAFFINITY */
#cmakedefine GLIBC_BEFORE_2_3_4_SCHED_SETAFFINITY 1

Expand Down Expand Up @@ -712,6 +709,8 @@
/* The size of `size_t', as computed by sizeof. */
#define SIZEOF_SIZE_T @SIZEOF_SIZE_T@

#cmakedefine01 HAVE_GNU_STRERROR_R

/* Define to 1 if the system has the type `struct sockaddr'. */
#cmakedefine HAVE_STRUCT_SOCKADDR 1

Expand Down
14 changes: 14 additions & 0 deletions src/mono/cmake/configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ include(CheckTypeSize)
include(CheckStructHasMember)
include(CheckSymbolExists)
include(CheckCCompilerFlag)
include(CheckCSourceCompiles)

# Apple platforms like macOS/iOS allow targeting older operating system versions with a single SDK,
# the mere presence of a symbol in the SDK doesn't tell us whether the deployment target really supports it.
Expand Down Expand Up @@ -124,6 +125,19 @@ check_type_size("long" SIZEOF_LONG)
check_type_size("long long" SIZEOF_LONG_LONG)
check_type_size("size_t" SIZEOF_SIZE_T)

set(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
check_c_source_compiles(
"
#include <string.h>
int main(void)
{
char buffer[1];
char c = *strerror_r(0, buffer, 0);
return 0;
}
"
HAVE_GNU_STRERROR_R)

# ICONV
set(ICONV_LIB)
find_library(LIBICONV_FOUND iconv)
Expand Down
1 change: 0 additions & 1 deletion src/mono/cmake/defines-todo.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#option (MAJOR_IN_MKDEV "Define to 1 if `major', `minor', and `makedev' are declared in <mkdev.h>.")
#option (MAJOR_IN_SYSMACROS "Define to 1 if `major', `minor', and `makedev' are declared in <sysmacros.h>.")
#option (STRERROR_R_CHAR_P "Define to 1 if strerror_r returns char *.")
#option (HAVE_LIBICONV "Define to 1 if you have the `iconv' library (-liconv).")
#option (ANDROID_UNIFIED_HEADERS "Whether Android NDK unified headers are used")
#option (MONO_DL_NEED_USCORE "Does dlsym require leading underscore.")
Expand Down
21 changes: 4 additions & 17 deletions src/mono/mono/component/debugger-agent.c
Original file line number Diff line number Diff line change
Expand Up @@ -2541,7 +2541,6 @@ try_process_suspend (void *the_tls, MonoContext *ctx, gboolean from_breakpoint)
static void
suspend_vm (void)
{
gboolean tp_suspend = FALSE;
mono_loader_lock ();

mono_coop_mutex_lock (&suspend_mutex);
Expand All @@ -2557,12 +2556,6 @@ suspend_vm (void)
}

mono_coop_mutex_unlock (&suspend_mutex);

if (suspend_count == 1)
/*
* Suspend creation of new threadpool threads, since they cannot run
*/
tp_suspend = TRUE;
Copy link
Member

Choose a reason for hiding this comment

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

this is no longer used because this code from mono/mono was undefined in ENABLE_NETCORE and removed in dotnet/runtime: https://github.com/mono/mono/blob/8b3b6666a858e02137b192c923727bcfd00ef620/mono/mini/debugger-agent.c#L2873-L2876

@lambdageek @vargaz do you know if that is intentional, i.e. do we no longer need to suspend creating threadpool threads? or is this just something that was missed while porting to dotnet/runtime now that the threadpool works differently?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe @vargaz remembers. I think we don't need it anymore - the old threadpool had a native Monitor thread that was responsible for monitoring workers. So the debugger stopped all the managed worker threads, but it didn't have any idea about the monitor thread. In netcore, we don't have a native monitor thread - everything is done by managed threads. So when the debugger suspends the runtime, it will suspend the thread pool worker creation, too.

Copy link
Member

Choose a reason for hiding this comment

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

Ok sounds good then :)

mono_loader_unlock ();
}

Expand All @@ -2576,7 +2569,6 @@ static void
resume_vm (void)
{
g_assert (is_debugger_thread ());
gboolean tp_resume = FALSE;

mono_loader_lock ();

Expand All @@ -2599,8 +2591,6 @@ resume_vm (void)
mono_coop_mutex_unlock (&suspend_mutex);
//g_assert (err == 0);

if (suspend_count == 0)
tp_resume = TRUE;
mono_loader_unlock ();
}

Expand Down Expand Up @@ -5257,15 +5247,15 @@ decode_vtype (MonoType *t, MonoDomain *domain, gpointer void_addr, gpointer void
{
guint8 *addr = (guint8*)void_addr;
guint8 *buf = (guint8*)void_buf;
gboolean is_enum;
MonoClass *klass;
MonoClassField *f;
int nfields;
gpointer iter = NULL;
MonoDomain *d;
ErrorCode err;

is_enum = decode_byte (buf, &buf, limit);
/* is_enum, ignored */
decode_byte (buf, &buf, limit);
if (CHECK_PROTOCOL_VERSION(2, 61))
decode_byte (buf, &buf, limit);
klass = decode_typeid (buf, &buf, limit, &d, &err);
Expand Down Expand Up @@ -5487,7 +5477,6 @@ decode_value_internal (MonoType *t, int type, MonoDomain *domain, guint8 *addr,
} else if (type == MONO_TYPE_VALUETYPE) {
ERROR_DECL (error);
guint8 *buf2;
gboolean is_enum;
MonoClass *klass;
MonoDomain *d;
guint8 *vtype_buf;
Expand All @@ -5499,7 +5488,7 @@ decode_value_internal (MonoType *t, int type, MonoDomain *domain, guint8 *addr,
* Same as the beginning of the handle_vtype case above.
*/
buf2 = buf;
is_enum = decode_byte (buf, &buf, limit);
decode_byte (buf, &buf, limit);
decode_byte (buf, &buf, limit); //ignore is boxed
klass = decode_typeid (buf, &buf, limit, &d, &err);
if (err != ERR_NONE)
Expand Down Expand Up @@ -8927,7 +8916,7 @@ thread_commands (int command, guint8 *p, guint8 *end, Buffer *buf)

for (int i = 0; i < tls->frame_count; i++)
{
PRINT_DEBUG_MSG(1, "[dbg] Searching Context [%d] - [%lld] - [%lld]\n", i, (uint64_t) MONO_CONTEXT_GET_SP (&tls->frames [i]->ctx), sp_received);
PRINT_DEBUG_MSG(1, "[dbg] Searching Context [%d] - [%" PRIu64 "] - [%" PRId64 "]\n", i, (uint64_t) MONO_CONTEXT_GET_SP (&tls->frames [i]->ctx), sp_received);
if (sp_received == (uint64_t)MONO_CONTEXT_GET_SP (&tls->frames [i]->ctx)) {
buffer_add_int(buf, i);
break;
Expand Down Expand Up @@ -9625,8 +9614,6 @@ object_commands (int command, guint8 *p, guint8 *end, Buffer *buf)
buffer_add_typeid (buf, obj->vtable->domain, mono_class_from_mono_type_internal (((MonoReflectionType*)obj->vtable->type)->type));
break;
case CMD_OBJECT_REF_GET_VALUES_ICORDBG: {
gpointer iter;
iter = NULL;
len = 1;
MonoClass *dummy_class;
int field_token = decode_int (p, &p, end);
Expand Down
6 changes: 3 additions & 3 deletions src/mono/mono/component/debugger-engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -715,16 +715,16 @@ ss_req_acquire (MonoInternalThread *thread)
for (i = 0; i < the_ss_reqs->len; ++i) {
SingleStepReq *current_req = (SingleStepReq *)g_ptr_array_index (the_ss_reqs, i);
if (current_req->thread == thread) {
current_req->refcount ++;
current_req->refcount ++;
req = current_req;
}
}
dbg_unlock ();
return req;
}

static int
ss_req_count ()
static int
ss_req_count (void)
{
return the_ss_reqs->len;
}
Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/component/event_pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <eventpipe/ep-event-instance.h>
#include <eventpipe/ep-session.h>

extern void ep_rt_mono_component_init (void);
static bool _event_pipe_component_inited = false;

struct _EventPipeProviderConfigurationNative {
Expand Down Expand Up @@ -287,7 +288,6 @@ MonoComponentEventPipe *
mono_component_event_pipe_init (void)
{
if (!_event_pipe_component_inited) {
extern void ep_rt_mono_component_init (void);
ep_rt_mono_component_init ();
_event_pipe_component_inited = true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/component/hot_reload.c
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ hot_reload_effective_table_slow (const MonoTableInfo **t, int *idx)
return;

GList *list = info->delta_image;
MonoImage *dmeta;
MonoImage *dmeta = NULL;
int ridx;
MonoTableInfo *table;
int g = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/eglib/gmarkup.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ parse_name (const char *p, const char *end, char **value)

l = (int)(p - start);
*value = g_malloc (l + 1);
if (*value == NULL)
if (*value == NULL || l <= 0)
return end;
strncpy (*value, start, l);
(*value) [l] = 0;
Expand Down
14 changes: 7 additions & 7 deletions src/mono/mono/eglib/gstr.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,11 @@ g_strerror (gint errnum)
size_t buff_len = sizeof (tmp_buff);
buff [0] = 0;

#ifndef STRERROR_R_CHAR_P
#if HAVE_GNU_STRERROR_R
buff = strerror_r (errnum, buff, buff_len);
if (!error_messages [errnum])
error_messages [errnum] = g_strdup (buff);
#else /* HAVE_GNU_STRERROR_R */
int r;
while ((r = strerror_r (errnum, buff, buff_len - 1))) {
if (r != ERANGE) {
Expand All @@ -261,17 +265,13 @@ g_strerror (gint errnum)
else
buff = g_realloc (buff, buff_len * 2);
buff_len *= 2;
//Spec is not clean on whether size argument includes space for null terminator or not
//Spec is not clean on whether size argument includes space for null terminator or not
}
if (!error_messages [errnum])
error_messages [errnum] = g_strdup (buff);
if (buff != tmp_buff)
g_free (buff);
#else /* STRERROR_R_CHAR_P */
buff = strerror_r (errnum, buff, buff_len);
if (!error_messages [errnum])
error_messages [errnum] = g_strdup (buff);
#endif /* STRERROR_R_CHAR_P */
#endif /* HAVE_GNU_STRERROR_R */

#else /* HAVE_STRERROR_R */
if (!error_messages [errnum])
Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/eventpipe/ds-rt-mono.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ ipc_get_process_id_disambiguation_key (

// All the format specifiers for the fields in the stat file are provided by 'man proc'.
int result_sscanf = sscanf (scan_start_position,
"%*c %*d %*d %*d %*d %*d %*u %*lu %*lu %*lu %*lu %*lu %*lu %*ld %*ld %*ld %*ld %*ld %*ld %llu \n",
"%*c %*d %*d %*d %*d %*d %*u %*u %*u %*u %*u %*u %*u %*d %*d %*d %*d %*d %*d %llu \n",
&start_time);

if (result_sscanf != 1) {
Expand Down
4 changes: 2 additions & 2 deletions src/mono/mono/eventpipe/ep-rt-mono.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#include <runtime_version.h>
#include <clretwallmain.h>

extern void InitProvidersAndEvents (void);

// EventPipe rt init state.
gboolean _ep_rt_mono_initialized;

Expand Down Expand Up @@ -1826,7 +1828,6 @@ profiler_eventpipe_thread_exited (
MonoProfiler *prof,
uintptr_t tid)
{
void ep_rt_mono_thread_exited (void);
ep_rt_mono_thread_exited ();
}

Expand Down Expand Up @@ -2414,7 +2415,6 @@ ep_rt_mono_os_environment_get_utf16 (ep_rt_env_array_utf16_t *env_array)
void
ep_rt_mono_init_providers_and_events (void)
{
extern void InitProvidersAndEvents (void);
InitProvidersAndEvents ();
}

Expand Down
Loading