From cd0f46d1f286b28d1289c2be4218c83b980f241d Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Fri, 10 May 2019 14:26:41 +0200 Subject: [esock] Add command (nif) function Add a command function to the socket API. Currently only used for changing global debug. OTP-15817 --- erts/emulator/nifs/common/socket_int.h | 1 + erts/emulator/nifs/common/socket_nif.c | 174 ++++++++++++++++++++++++++++++++- erts/preloaded/ebin/socket.beam | Bin 75044 -> 75444 bytes erts/preloaded/src/socket.erl | 32 +++++- 4 files changed, 200 insertions(+), 7 deletions(-) (limited to 'erts') diff --git a/erts/emulator/nifs/common/socket_int.h b/erts/emulator/nifs/common/socket_int.h index d6977be5aa..ac689e82b1 100644 --- a/erts/emulator/nifs/common/socket_int.h +++ b/erts/emulator/nifs/common/socket_int.h @@ -130,6 +130,7 @@ typedef unsigned int BOOLEAN_T; GLOBAL_ATOM_DEF(busy_poll); \ GLOBAL_ATOM_DEF(checksum); \ GLOBAL_ATOM_DEF(close); \ + GLOBAL_ATOM_DEF(command); \ GLOBAL_ATOM_DEF(connect); \ GLOBAL_ATOM_DEF(congestion); \ GLOBAL_ATOM_DEF(context); \ diff --git a/erts/emulator/nifs/common/socket_nif.c b/erts/emulator/nifs/common/socket_nif.c index adecbb3b6e..c7af19d646 100644 --- a/erts/emulator/nifs/common/socket_nif.c +++ b/erts/emulator/nifs/common/socket_nif.c @@ -659,6 +659,7 @@ typedef union { /* We should *eventually* use this instead of hard-coding the size (to 1) */ #define ESOCK_RECVMSG_IOVEC_SZ 1 +#define SOCKET_CMD_DEBUG 0x0001 #define SOCKET_SUPPORTS_OPTIONS 0x0001 #define SOCKET_SUPPORTS_SCTP 0x0002 @@ -948,6 +949,7 @@ extern char* erl_errno_id(int error); /* THIS IS JUST TEMPORARY??? */ * does the actual work. Except for the info function. * * nif_info + * nif_command * nif_supports * nif_open * nif_bind @@ -973,6 +975,7 @@ extern char* erl_errno_id(int error); /* THIS IS JUST TEMPORARY??? */ #define ESOCK_NIF_FUNCS \ ESOCK_NIF_FUNC_DEF(info); \ + ESOCK_NIF_FUNC_DEF(command); \ ESOCK_NIF_FUNC_DEF(supports); \ ESOCK_NIF_FUNC_DEF(open); \ ESOCK_NIF_FUNC_DEF(bind); \ @@ -1003,6 +1006,15 @@ ESOCK_NIF_FUNCS #undef ESOCK_NIF_FUNC_DEF +static BOOLEAN_T ecommand2command(ErlNifEnv* env, + ERL_NIF_TERM ecommand, + Uint16* command, + ERL_NIF_TERM* edata); +static ERL_NIF_TERM ncommand(ErlNifEnv* env, + Uint16 cmd, + ERL_NIF_TERM ecdata); +static ERL_NIF_TERM ncommand_debug(ErlNifEnv* env, ERL_NIF_TERM ecdata); + #if !defined(__WIN32__) /* And here comes the functions that does the actual work (for the most part) */ static ERL_NIF_TERM nsupports(ErlNifEnv* env, int key); @@ -2661,6 +2673,7 @@ static char str_exsend[] = "exsend"; // failed send GLOBAL_ATOM_DECL(busy_poll); \ GLOBAL_ATOM_DECL(checksum); \ GLOBAL_ATOM_DECL(close); \ + GLOBAL_ATOM_DECL(command); \ GLOBAL_ATOM_DECL(connect); \ GLOBAL_ATOM_DECL(congestion); \ GLOBAL_ATOM_DECL(context); \ @@ -2967,8 +2980,8 @@ static ESOCK_INLINE ErlNifEnv* esock_alloc_env(const char* slogan) * Utility and admin functions: * ---------------------------- * nif_info/0 + * nif_command/1 * nif_supports/1 - * (nif_debug/1) * * The "proper" socket functions: * ------------------------------ @@ -3055,6 +3068,107 @@ ERL_NIF_TERM nif_info(ErlNifEnv* env, } +/* ---------------------------------------------------------------------- + * nif_command + * + * Description: + * This function is intended to handle "various" commands. That is, + * commands and operations that are not part of the socket API proper. + * Currently it handles setting the global debug. Its a map with two + * attributes command and (command) data: + * #{command :: atom(), data :: term()} + * + * Command Data + * debug boolean() + * + */ + +static +ERL_NIF_TERM nif_command(ErlNifEnv* env, + int argc, + const ERL_NIF_TERM argv[]) +{ + ERL_NIF_TERM ecmd, ecdata, result; + Uint16 cmd; + + SGDBG( ("SOCKET", "nif_command -> entry with %d args\r\n", argc) ); + + if ((argc != 1) || + !IS_MAP(env, argv[0])) { + return enif_make_badarg(env); + } + ecmd = argv[0]; + + SGDBG( ("SOCKET", "nif_command -> " + "\r\n (e) command: %T" + "\r\n", ecmd) ); + + if (!ecommand2command(env, ecmd, &cmd, &ecdata)) { + SGDBG( ("SOCKET", "nif_command -> invalid command\r\n") ); + return esock_make_error(env, esock_atom_einval); + } + + SGDBG( ("SOCKET", "nif_command -> " + "\r\n command: %d" + "\r\n (e) command data: %T" + "\r\n", cmd, ecdata) ); + + result = ncommand(env, cmd, ecdata); + + SGDBG( ("SOCKET", "nif_command -> done with result: " + "\r\n %T" + "\r\n", result) ); + + return result; + +} + + +static +ERL_NIF_TERM ncommand(ErlNifEnv* env, Uint16 cmd, ERL_NIF_TERM ecdata) +{ + ERL_NIF_TERM result; + + SGDBG( ("SOCKET", "ncommand -> entry with 0x%lX\r\n", cmd) ); + + switch (cmd) { + case SOCKET_CMD_DEBUG: + result = ncommand_debug(env, ecdata); + break; + + default: + result = esock_make_error(env, esock_atom_einval); + break; + } + + return result; +} + + + +static +ERL_NIF_TERM ncommand_debug(ErlNifEnv* env, ERL_NIF_TERM ecdata) +{ + ERL_NIF_TERM result; + + /* The data *should* be a boolean() */ + + if (COMPARE(ecdata, esock_atom_true) == 0) { + data.dbg = TRUE; + result = esock_atom_ok; + } else if (COMPARE(ecdata, esock_atom_false) == 0) { + data.dbg = FALSE; + result = esock_atom_ok; + } else { + SGDBG( ("SOCKET", "ncommand_debug -> invalid debug value: %T\r\n", + ecdata) ); + result = esock_make_error(env, esock_atom_einval); + } + + return result; +} + + /* ---------------------------------------------------------------------- * nif_supports @@ -17545,6 +17659,59 @@ BOOLEAN_T ehow2how(unsigned int ehow, int* how) +/* ecommand2command - convert erlang command to "native" command (and data) + */ +static +BOOLEAN_T ecommand2command(ErlNifEnv* env, + ERL_NIF_TERM ecommand, + Uint16* command, + ERL_NIF_TERM* edata) +{ + size_t sz; + ERL_NIF_TERM ecmd; + + if (!IS_MAP(env, ecommand)) { + SGDBG( ("SOCKET", "ecommand2command -> (e)command not a map\r\n") ); + return FALSE; + } + + /* The map shall have exactly two attrbutes: + * 'command' and 'data' + */ + if (!enif_get_map_size(env, ecommand, &sz) || (sz != 2)) { + SGDBG( ("SOCKET", "ecommand2command -> comamnd map size invalid\r\n") ); + return FALSE; + } + + /* Get the command value, and transform into integer + * (might as well do that, since theer is no point in + * extracting the data if command is invalid). + */ + if (!GET_MAP_VAL(env, ecommand, esock_atom_command, &ecmd)) { + SGDBG( ("SOCKET", "ecommand2command -> command attribute not found\r\n") ); + return FALSE; + } + if (COMPARE(ecmd, esock_atom_debug) == 0) { + *command = SOCKET_CMD_DEBUG; + } else { + SGDBG( ("SOCKET", "ecommand2command -> unknown command %T\r\n", ecmd) ); + return FALSE; + } + + /* Get the command data value, we do *not* convert it to + * the native form (here) since it may "in theory" be complex. + */ + if (!GET_MAP_VAL(env, ecommand, esock_atom_data, edata)) { + SGDBG( ("SOCKET", "ecommand2command -> (command) data not found\r\n") ); + return FALSE; + } + + return TRUE; +} + + + + #if defined(HAVE_SYS_UN_H) || defined(SO_BINDTODEVICE) /* strnlen doesn't exist everywhere */ /* @@ -18955,12 +19122,9 @@ ErlNifFunc socket_funcs[] = // Some utility and support functions {"nif_info", 0, nif_info, 0}, {"nif_supports", 1, nif_supports, 0}, - // {"nif_debug", 1, nif_debug, 0}, - // {"nif_command", 1, nif_command, 0}, + {"nif_command", 1, nif_command, 0}, // The proper "socket" interface - // nif_open/1 is used when we already have a file descriptor - // {"nif_open", 1, nif_open, 0}, {"nif_open", 4, nif_open, 0}, {"nif_bind", 2, nif_bind, 0}, {"nif_connect", 2, nif_connect, 0}, diff --git a/erts/preloaded/ebin/socket.beam b/erts/preloaded/ebin/socket.beam index 134b4eac13..d19e0c40b4 100644 Binary files a/erts/preloaded/ebin/socket.beam and b/erts/preloaded/ebin/socket.beam differ diff --git a/erts/preloaded/src/socket.erl b/erts/preloaded/src/socket.erl index ae1ffdb4ac..3a43504f8f 100644 --- a/erts/preloaded/src/socket.erl +++ b/erts/preloaded/src/socket.erl @@ -26,9 +26,12 @@ %% Administrative and "global" utility functions -export([ on_load/0, on_load/1, + + ensure_sockaddr/1, + + command/1, info/0, - supports/0, supports/1, supports/2, supports/3, - ensure_sockaddr/1 + supports/0, supports/1, supports/2, supports/3 ]). -export([ @@ -63,6 +66,8 @@ select_ref/0, select_info/0, + command/0, + domain/0, type/0, protocol/0, @@ -135,6 +140,18 @@ ]). +%% The command type has the general form: +%% #{ +%% command := atom(), +%% data := term() +%% } +%% But only certain values are actually valid, so the type gets the form: +-type debug_command() :: #{ + command := debug, + data := boolean() + }. +-type command() :: debug_command(). + -type uint8() :: 0..16#FF. -type uint16() :: 0..16#FFFF. -type uint20() :: 0..16#FFFFF. @@ -867,6 +884,14 @@ info() -> nif_info(). +-spec command(Command) -> term() when + Command :: command(). + +command(#{command := debug, + data := Dbg} = Command) when is_boolean(Dbg) -> + nif_command(Command). + + %% =========================================================================== %% @@ -3845,6 +3870,9 @@ error(Reason) -> nif_info() -> erlang:nif_error(undef). +nif_command(_Command) -> + erlang:nif_error(undef). + nif_supports(_Key) -> erlang:nif_error(undef). -- cgit v1.2.3 From b7b650e20da47861f3d2e5ac32f720056391bf43 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Fri, 10 May 2019 15:18:55 +0200 Subject: [esock] Add debug function Introduced a debug/1 function and made the command/1 internal. OTP-15817 --- erts/preloaded/ebin/socket.beam | Bin 75444 -> 75584 bytes erts/preloaded/src/socket.erl | 19 ++++++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) (limited to 'erts') diff --git a/erts/preloaded/ebin/socket.beam b/erts/preloaded/ebin/socket.beam index d19e0c40b4..c4680c2baa 100644 Binary files a/erts/preloaded/ebin/socket.beam and b/erts/preloaded/ebin/socket.beam differ diff --git a/erts/preloaded/src/socket.erl b/erts/preloaded/src/socket.erl index 3a43504f8f..e9a76dc1e9 100644 --- a/erts/preloaded/src/socket.erl +++ b/erts/preloaded/src/socket.erl @@ -29,7 +29,8 @@ ensure_sockaddr/1, - command/1, + debug/1, + %% command/1, info/0, supports/0, supports/1, supports/2, supports/3 ]). @@ -66,7 +67,7 @@ select_ref/0, select_info/0, - command/0, + %% command/0, domain/0, type/0, @@ -150,7 +151,7 @@ command := debug, data := boolean() }. --type command() :: debug_command(). +%% -type command() :: debug_command(). -type uint8() :: 0..16#FF. -type uint16() :: 0..16#FFFF. @@ -884,8 +885,16 @@ info() -> nif_info(). --spec command(Command) -> term() when - Command :: command(). +-spec debug(D) -> ok when + D :: boolean(). + +debug(D) when is_boolean(D) -> + command(#{command => debug, + data => D}). + + +-spec command(Command) -> ok when + Command :: debug_command(). command(#{command := debug, data := Dbg} = Command) when is_boolean(Dbg) -> -- cgit v1.2.3 From e7ee9e1b3810d695f910d8a2fcdb38b04c8042b7 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Fri, 10 May 2019 15:51:05 +0200 Subject: [esock|test] Add test case for debug OTP-15817 --- erts/emulator/test/socket_SUITE.erl | 52 +++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'erts') diff --git a/erts/emulator/test/socket_SUITE.erl b/erts/emulator/test/socket_SUITE.erl index d8cb1013e9..3a45339ce1 100644 --- a/erts/emulator/test/socket_SUITE.erl +++ b/erts/emulator/test/socket_SUITE.erl @@ -67,6 +67,9 @@ %% Test cases -export([ + %% *** API Misc *** + api_m_debug/1, + %% *** API Basic *** api_b_open_and_close_udp4/1, api_b_open_and_close_tcp4/1, @@ -582,6 +585,7 @@ use_group(Group, Env, Default) -> groups() -> [{api, [], api_cases()}, + {api_misc, [], api_misc_cases()}, {api_basic, [], api_basic_cases()}, {api_async, [], api_async_cases()}, {api_options, [], api_options_cases()}, @@ -657,12 +661,18 @@ groups() -> api_cases() -> [ + {group, api_misc}, {group, api_basic}, {group, api_async}, {group, api_options}, {group, api_op_with_timeout} ]. +api_misc_cases() -> + [ + api_m_debug + ]. + api_basic_cases() -> [ api_b_open_and_close_udp4, @@ -1633,6 +1643,48 @@ quiet_mode(Config) -> +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% %% +%% API MISC %% +%% %% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%% A simple test case that tests that the global debug can be channged. +%% At the same time, it will test the info function (since it uses it +%% for verification). + +api_m_debug(suite) -> + []; +api_m_debug(doc) -> + []; +api_m_debug(_Config) when is_list(_Config) -> + ?TT(?SECS(5)), + tc_try(api_m_debug, + fun() -> + ok = api_m_debug() + end). + +api_m_debug() -> + i("get initial info"), + #{debug := D0} = socket:info(), + D1 = not D0, + i("set new debug (~w => ~w)", [D0, D1]), + ok = socket:debug(D1), + i("get updated info (~w)", [D1]), + #{debug := D1} = socket:info(), + D2 = not D1, + i("set new debug (~w => ~w)", [D1, D2]), + ok = socket:debug(D2), + i("get updated info (~w)", [D2]), + #{debug := D2} = socket:info(), + i("ok"), + ok. + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% %% -- cgit v1.2.3 From 6801adfbe71a633b1e36a8981bfa7001ff476607 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Tue, 25 Jun 2019 17:32:21 +0200 Subject: [esock] Moved new command inside ifdef Build failed on windows because of misplaced ifdef's (of new command functions). OTP-15817 --- erts/emulator/nifs/common/socket_nif.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'erts') diff --git a/erts/emulator/nifs/common/socket_nif.c b/erts/emulator/nifs/common/socket_nif.c index c7af19d646..0145cae31b 100644 --- a/erts/emulator/nifs/common/socket_nif.c +++ b/erts/emulator/nifs/common/socket_nif.c @@ -1006,6 +1006,9 @@ ESOCK_NIF_FUNCS #undef ESOCK_NIF_FUNC_DEF +#if !defined(__WIN32__) + +/* And here comes the functions that does the actual work (for the most part) */ static BOOLEAN_T ecommand2command(ErlNifEnv* env, ERL_NIF_TERM ecommand, Uint16* command, @@ -1015,8 +1018,6 @@ static ERL_NIF_TERM ncommand(ErlNifEnv* env, ERL_NIF_TERM ecdata); static ERL_NIF_TERM ncommand_debug(ErlNifEnv* env, ERL_NIF_TERM ecdata); -#if !defined(__WIN32__) -/* And here comes the functions that does the actual work (for the most part) */ static ERL_NIF_TERM nsupports(ErlNifEnv* env, int key); static ERL_NIF_TERM nsupports_options(ErlNifEnv* env); static ERL_NIF_TERM nsupports_options_socket(ErlNifEnv* env); @@ -3088,6 +3089,9 @@ ERL_NIF_TERM nif_command(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) { +#if defined(__WIN32__) + return enif_raise_exception(env, MKA(env, "notsup")); +#else ERL_NIF_TERM ecmd, ecdata, result; Uint16 cmd; @@ -3121,9 +3125,11 @@ ERL_NIF_TERM nif_command(ErlNifEnv* env, return result; +#endif } +#if !defined(__WIN32__) static ERL_NIF_TERM ncommand(ErlNifEnv* env, Uint16 cmd, ERL_NIF_TERM ecdata) { @@ -3167,7 +3173,7 @@ ERL_NIF_TERM ncommand_debug(ErlNifEnv* env, ERL_NIF_TERM ecdata) return result; } - +#endif /* ---------------------------------------------------------------------- -- cgit v1.2.3 From 40bf3831e0aae6d77cdcdbcc96fa916c22233c96 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Thu, 4 Jul 2019 14:51:28 +0200 Subject: [esock] Fixed debug "file" Debug printouts is done to "dbgout", but the dbg macro flushed "stdout" (which was the default). So, in order to make the macro work properly in all cases, we rename dbgout to esock_dbgout and make it extern (was static), and then used that in the macro. OTP-15817 --- erts/emulator/nifs/common/socket_dbg.c | 16 ++++++++-------- erts/emulator/nifs/common/socket_dbg.h | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'erts') diff --git a/erts/emulator/nifs/common/socket_dbg.c b/erts/emulator/nifs/common/socket_dbg.c index 7dfc4b77bc..1180466c4c 100644 --- a/erts/emulator/nifs/common/socket_dbg.c +++ b/erts/emulator/nifs/common/socket_dbg.c @@ -37,23 +37,23 @@ #define TNAME(__T__) enif_thread_name( __T__ ) #define TSNAME() TNAME(TSELF()) -static FILE* dbgout = NULL; +FILE* esock_dbgout = NULL; extern void esock_dbg_init(char* filename) { if (filename != NULL) { if (strcmp(filename, ESOCK_DBGOUT_DEFAULT) == 0) { - dbgout = stdout; + esock_dbgout = stdout; } else if (strcmp(filename, ESOCK_DBGOUT_UNIQUE) == 0) { - char template[] = "/tmp/esock-dbg-XXXXXX"; - dbgout = fdopen(mkstemp(template), "w+"); + char template[] = "/tmp/esock-dbg-XXXXXX"; + esock_dbgout = fdopen(mkstemp(template), "w+"); } else { - dbgout = fopen(filename, "w+"); + esock_dbgout = fopen(filename, "w+"); } } else { char template[] = "/tmp/esock-dbg-XXXXXX"; - dbgout = fdopen(mkstemp(template), "w+"); + esock_dbgout = fdopen(mkstemp(template), "w+"); } } @@ -87,9 +87,9 @@ void esock_dbg_printf( const char* prefix, const char* format, ... ) if (res > 0) { va_start (args, format); - enif_vfprintf (dbgout, f, args); + enif_vfprintf (esock_dbgout, f, args); va_end (args); - fflush(dbgout); + fflush(esock_dbgout); } return; diff --git a/erts/emulator/nifs/common/socket_dbg.h b/erts/emulator/nifs/common/socket_dbg.h index 47739b46da..8fce211a8a 100644 --- a/erts/emulator/nifs/common/socket_dbg.h +++ b/erts/emulator/nifs/common/socket_dbg.h @@ -40,12 +40,12 @@ #endif typedef unsigned long long llu_t; - +extern FILE* esock_dbgout; // Initiated by the 'init' function #define ESOCK_DBG_PRINTF( ___COND___ , proto ) \ if ( ___COND___ ) { \ esock_dbg_printf proto; \ - fflush(stdout); \ + fflush(esock_dbgout); \ } -- cgit v1.2.3 From 6605b3965064a3edce1260e6d77fba55817844b5 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Thu, 4 Jul 2019 15:33:14 +0200 Subject: [esock|test] Add conditional skip to debug test case The api_m_debug test case seems to trigger a gcc bug that causes a segfault on an ancient Fedora 16 VM (with gcc version 4.6.3-2). The simplest way to avoid this is to test for this specific (gcc) version... OTP-15817 --- erts/emulator/test/socket_SUITE.erl | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'erts') diff --git a/erts/emulator/test/socket_SUITE.erl b/erts/emulator/test/socket_SUITE.erl index 3a45339ce1..d51e7fa464 100644 --- a/erts/emulator/test/socket_SUITE.erl +++ b/erts/emulator/test/socket_SUITE.erl @@ -1664,10 +1664,34 @@ api_m_debug(doc) -> api_m_debug(_Config) when is_list(_Config) -> ?TT(?SECS(5)), tc_try(api_m_debug, + fun() -> has_bugfree_gcc() end, fun() -> ok = api_m_debug() end). +%% For some reason this test case triggers a gcc bug, which causes +%% a segfault, on an ancient Fedora 16 VM. So, check the version of gcc... +%% Not pretty, but the simplest way to skip (without actually testing for the host). +has_bugfree_gcc() -> + has_bugfree_gcc(os:type()). + +%% Make sure we are on linux +has_bugfree_gcc({unix, linux}) -> + has_bugfree_gcc2(os:cmd("cat /etc/issue")); +has_bugfree_gcc(_) -> + ok. + +%% Make sure we are on Fedora 16 +has_bugfree_gcc2("Fedora release 16 " ++ _) -> + has_bugfree_gcc3(os:cmd("gcc --version")); +has_bugfree_gcc2(_) -> + ok. + +has_bugfree_gcc3("gcc (GCC) 4.6.3 20120306 (Red Hat 4.6.3-2" ++ _) -> + skip("Buggy GCC"); +has_bugfree_gcc3(_) -> + ok. + api_m_debug() -> i("get initial info"), #{debug := D0} = socket:info(), -- cgit v1.2.3 From 13b2197d49d189c32f3a268ed671166ad79767aa Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Thu, 4 Jul 2019 16:10:49 +0200 Subject: [esock] Format buffer length Corrected calculation of buffer length for format(ed) string. OTP-15817 --- erts/emulator/nifs/common/socket_dbg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'erts') diff --git a/erts/emulator/nifs/common/socket_dbg.c b/erts/emulator/nifs/common/socket_dbg.c index 1180466c4c..0005575017 100644 --- a/erts/emulator/nifs/common/socket_dbg.c +++ b/erts/emulator/nifs/common/socket_dbg.c @@ -67,7 +67,7 @@ extern void esock_dbg_printf( const char* prefix, const char* format, ... ) { va_list args; - char f[512 + sizeof(format)]; // This has to suffice... + char f[512 + strlen(format)]; // This has to suffice... char stamp[30]; int res; -- cgit v1.2.3