summaryrefslogtreecommitdiff
path: root/erts/emulator/beam/sys.h
Commit message (Collapse)AuthorAgeFilesLines
* Update copyright yearRickard Green2020-03-131-1/+1
|
* Adjustable busy port parameters for default driversRickard Green2020-01-131-23/+0
|
* Merge branch 'sverker/dist-entry-refc-bug/ERL-1044/OTP-16224' into maintRickard Green2019-11-061-1/+25
|\ | | | | | | | | | | * sverker/dist-entry-refc-bug/ERL-1044/OTP-16224: erts: Fix bug causing leak of DistEntry erts: Fix write-after-free bug for DistEntry
| * erts: Fix write-after-free bug for DistEntrySverker Eriksson2019-10-251-1/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Symptom: VM crash caused by write-after-free on reference counter of DistEntry magic binary. Problem: DistEntry reference counter to low and is therefore decremented after deallocation. Scenario: 1. Thread A do lookup of DistEntry without refc++ 2. Thread B do refc-- from 1 to 0 and schedules pending delete. 3. Thread A calls erts_build_dhandle() which does refc++ from 0 to 1. 4. Thread B executes pending delete and does refc-- from 1 to 0. DistEntry now has refc==0 while it's referred by a live dhandle term which may later lead to write-after-free on the reference counter.
* | erts: Skip ERTS_NOINLINE on non-GCC-compatible compilersJohn Högberg2019-04-081-2/+0
| | | | | | | | | | | | | | | | | | | | __declspec(noinline) works fine on MSVC but requires us to place the macro before a function rather than after, which in turn causes early versions of GCC to puke since they only accept __attribute__ at the end of a function declaration. Since this is a new macro that previously only saw use in beam_emu, I figured it's easiest to leave it disabled on MSVC.
* | stdlib: fix re:replace on LTO buildsSergei Trofimovich2019-03-291-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fabio Coatti reported elixir build failure in https://bugs.gentoo.org/681778. The minimal reproducer looks like that (from otp git tree): $ ./configure CFLAGS='-O2 -flto' LDFLAGS='-O2 -flto=8' $ make $ ERL_TOP=$PWD \ PATH=$ERL_TOP/bin:$PATH \ \ bin/erl \ \ -noshell -eval 're:replace("a","b","c",[{return,list}]).' \ -s erlang halt {"init terminating in do_boot",{badarg,[{re,replace,["a","b","c",[{return,list}]], [{file,"re.erl"},{line,362}]}, {erl_eval,do_apply,6,[{file,"erl_eval.erl"},{line,680}]}, {init,start_it,1,[]}, {init,start_em,1,[]}, {init,do_boot,3,[]}]}} init terminating in do_boot ({badarg,[{re,replace,[[_],[_],[_],[_]],[{_},{_}]}, {erl_eval,do_apply,6,[{_},{_}]},{init,start_it,1,[]},{init,start_em,1,[]},{init,do_boot,3,[]}]}) Crash dump is being written to: erl_crash.dump...done The failure happens in libpcre2 where stack overflow is mis-identified at function entry of erts_pcre_compile2() compile_regex() if (PUBL(stack_guard) != NULL && PUBL(stack_guard)()) { *errorcodeptr= ERR85; return FALSE; } The stack "overflow" detection happens in thr_wrapper() ethr_set_stacklimit__() because the stack usage code relies on the fact that ethr_set_stacklimit__() and similar functions don't get inlined into callers for stack growth measurement. Before the change inlining avoidance was achieved by putting functions into standalone translation units. LTO makes this technique inefficient. The change marks functions explicitly as __attribute__((__noinline__)) on gcc. Reported-by: Fabio Coatti Bug: https://bugs.gentoo.org/681778 Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
* | sys.h: Check for overflow checking aritmethic builtinsBjörn Gustavsson2019-03-061-0/+17
| | | | | | | | | | | | | | | | | | | | | | Let sys.h define HAVE_OVERFLOW_CHECK_BUILTINS if the compiler supports __builtin_mul_overflow() and the other overflow checking builtins. The test is intentionally made in a sys.h and not as a configure test. On Windows, beam_emu.c is always compiled using gcc, but the other files are usually compiled with Microsoft's C compiler. With the test in the header file, HAVE_OVERFLOW_CHECK_BUILTINS will be defined when compiling beam_emu.c.
* | erts: Add magic port control numbersSverker Eriksson2019-01-281-0/+9
| | | | | | | | | | to increase the probablity of a nice badarg from erlang:port_control.
* | erts: Add new module 'atomics'Sverker Eriksson2018-11-151-0/+3
|/
* Update copyright yearHenrik Nord2018-06-181-1/+1
|
* Correct overflow in ERTS_SINT64_MIN and add macros for 16/32John Högberg2018-03-231-19/+21
| | | | | This also removes a redundant #ifdef soup that had hidden the problem on most platforms.
* erts: Fix some zero size sys_memcpySverker Eriksson2018-03-201-3/+1
|
* erts: Make sys_memcpy and friends inline functionsSverker Eriksson2018-03-201-21/+67
| | | | | | | | to avoid argument-evaluated-twice bugs like in macro DMC_PUSH. Had to shuffle around some #include and #define to make erl_child_setup build debug target.
* Check the arguments to sys_memcpy and friendsJohn Högberg2018-03-091-10/+30
| | | | | | | Passing NULL is undefined behavior and unconditionally executing these may result in the compiler optimizing away a later NULL check. It can often work since the pointer isn't touched when the length is 0, but it's a major footgun. See ERL-573.
* Replace the libc environment with a thread-safe emulationJohn Högberg2018-01-031-19/+18
| | | | | | | | | | | | | | putenv(3) and friends aren't thread-safe regardless of how you slice it; a global lock around all environment operations (like before) keeps things safe as far as our own operations go, but we have absolutely no control over what libc or a library dragged in by a driver/NIF does -- they're free to call getenv(3) or putenv(3) without honoring our lock. This commit solves this by setting up an "emulated" environment which can't be touched without going through our interfaces. Third-party libraries can still shoot themselves in the foot but benign uses of os:putenv/2 will no longer risk crashing the emulator.
* Merge branch 'lukas/erts/use_SIGRTMIN_for_sys_suspend/OTP-14682'Lukas Larsson2017-10-121-3/+8
|\ | | | | | | | | * lukas/erts/use_SIGRTMIN_for_sys_suspend/OTP-14682: erts: Use SIGRTMIN on linux for sys_suspend
| * erts: Use SIGRTMIN on linux for sys_suspendLukas Larsson2017-10-121-3/+8
| | | | | | | | | | | | The Linux real-time signal is better used on Linux for suspending schedulers during shutdown as it doesn't collide with SIGUSR2 usage of other applications.
* | Merge branch 'rickard/null-chars/ERL-370/OTP-14543'Rickard Green2017-10-121-0/+48
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | * rickard/null-chars/ERL-370/OTP-14543: Don't allow null chars in various strings Conflicts: erts/emulator/beam/erl_alloc.types erts/preloaded/ebin/erlang.beam
| * | Don't allow null chars in various stringsRickard Green2017-10-111-0/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Various places that now reject null chars inside strings - Primitive file operations reject it in filenames. - Primitive environment variable operations reject it in names and values. - os:cmd() reject it in its input. Also '=' characters are rejected by primitive environment variable operations in environment variable names. Documentation has been updated to document null characters in these types of data as invalid. Currently these operations accept null chars at the end of strings, but that will change in the future.
* | | erts: Move all I/O polling to a seperate threadLukas Larsson2017-10-021-4/+0
| | |
* | | erts: Add number of enif_select's to check_io_debugSverker Eriksson2017-09-151-0/+1
| | |
* | | erts: Remove undocumented driver_eventSverker Eriksson2017-09-151-1/+0
| | |
* | | erts: Refactor move check_io interface from sys to check_ioSverker Eriksson2017-09-151-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | # Conflicts: # erts/emulator/beam/erl_process.c # erts/emulator/beam/sys.h # erts/emulator/sys/common/erl_check_io.c # erts/emulator/sys/common/erl_check_io.h # erts/emulator/sys/unix/sys.c
* | | Merge branch 'maint'John Högberg2017-09-111-0/+8
|\ \ \ | |/ /
| * | Replace ad-hoc MIN/MAX macros with common onesJohn Högberg2017-09-071-0/+8
| | | | | | | | | | | | | | | | | | Besides being noisy, they were already defined by a global Unix- specific header, causing the Windows build to fail if one forgot to define them.
* | | Merge branch 'maint'Rickard Green2017-09-051-4/+0
|\ \ \ | |/ / | | / | |/ |/| | | | | | | * maint: Bug fixes of statistics(wall_clock) and statistics(runtime) Conflicts: erts/emulator/beam/erl_time_sup.c
| * Bug fixes of statistics(wall_clock) and statistics(runtime)Rickard Green2017-09-041-4/+0
| |
| * Merge branch 'rickard/statistics/OTP-14484' into maint-20Erlang/OTP2017-06-301-4/+4
| |\ | | | | | | | | | | | | * rickard/statistics/OTP-14484: Fix statistics(wall_clock) and statistics(runtime) implementation
* | | erts: Replace usage of all erts_smp prefixes to just ertsLukas Larsson2017-07-171-143/+7
| | |
* | | erts: Remove ERTS_SMP and USE_THREAD definesLukas Larsson2017-07-171-27/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This refactor was done using the unifdef tool like this: for file in $(find erts/ -name *.[ch]); do unifdef -t -f defile -o $file $file; done where defile contained: #define ERTS_SMP 1 #define USE_THREADS 1 #define DDLL_SMP 1 #define ERTS_HAVE_SMP_EMU 1 #define SMP 1 #define ERL_BITS_REENTRANT 1 #define ERTS_USE_ASYNC_READY_Q 1 #define FDBLOCK 1 #undef ERTS_POLL_NEED_ASYNC_INTERRUPT_SUPPORT #define ERTS_POLL_ASYNC_INTERRUPT_SUPPORT 0 #define ERTS_POLL_USE_WAKEUP_PIPE 1 #define ERTS_POLL_USE_UPDATE_REQUESTS_QUEUE 1 #undef ERTS_HAVE_PLAIN_EMU #undef ERTS_SIGNAL_STATE
* | | erts: ensure alignment of VM core typesMikael Pettersson2017-07-071-9/+9
| | |
* | | Merge pull request #1491 from eltex-ecss/e2k_supportLukas Larsson2017-07-031-1/+1
|\ \ \ | | | | | | | | | | | | | | | | Support e2k platform OTP-14492
| * | | Support e2k architectureBoris Bochkarev2017-06-231-1/+1
| |/ /
* | | Merge branch 'maint-19' into maintJohn Högberg2017-06-271-4/+4
|\ \ \ | |/ / |/| / | |/ | | | | | | | | | | | | | | | | | | * maint-19: Updated OTP version Update release notes Update version numbers Fix statistics(wall_clock) and statistics(runtime) implementation fixup! erts: Cleanup dropped port tasks correctly erts: Add tests to detect port close race Add a testcase for OTP-13939/ERL-193 erts: Cleanup dropped port tasks correctly Mark socket disconnected on tcp_send_or_shutdown_error
| * Fix statistics(wall_clock) and statistics(runtime) implementationRickard Green2017-06-221-4/+4
| |
| * erts: Make sigterm signal safe for non-smp beamBjörn-Egil Dahlberg2017-03-211-0/+6
| | | | | | | | | | | | The signal handler will now schedule a sigterm message instead of sending the message in the signal handler. The signal handler must refrain from memory allocations and thus the event is scheduled.
* | Update copyright yearRaimo Niskanen2017-05-041-1/+1
| |
* | Merge branch 'rickard/pcre-8.40'Rickard Green2017-04-111-0/+2
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | OTP-14331 * rickard/pcre-8.40: Update documentation Update README.pcre_update.md Stack guard for PCRE Adjust for incompatibility between PCRE 8.40 and perl 5.22.1 Generate re replacement and split tests with perl vsn 5.22.1 Fix re_SUITE:pcre_compile_workspace_overflow/1 Skip line with lockout of modifiers in PCRE tests Update tests for PCRE version 8.40 Update PCRE to version 8.40 Conflicts: erts/emulator/beam/beam_debug.c
| * | Stack guard for PCRERickard Green2017-04-071-0/+2
| |/
| * Update copyright yearRickard Green2017-03-101-1/+1
| |
* | erts: Don't allocate memory during signal handlingBjörn-Egil Dahlberg2017-03-221-0/+6
| | | | | | | | | | Allocations and message sending are now scheduled by a signal, via a signal state bitmap, instead of doing it directly in the signal handler.
* | Implement erts_refc_inc_unless()Rickard Green2017-02-061-0/+55
| |
* | Merge branch 'maint'Rickard Green2017-02-061-11/+117
|\ \ | |/ | | | | | | | | | | | | * maint: Atomic reference count of binaries also in non-SMP Conflicts: erts/emulator/beam/erl_fun.c
| * Merge branch 'rickard/binary-refc' into maintRickard Green2017-02-061-11/+117
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | OTP-14202 * rickard/binary-refc: Atomic reference count of binaries also in non-SMP Conflicts: erts/emulator/beam/beam_bp.c
| | * Atomic reference count of binaries also in non-SMPRickard Green2017-02-061-11/+117
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | NIF resources was not handled in a thread-safe manner in the runtime system without SMP support. As a consequence of this fix, the following driver functions are now thread-safe also in the runtime system without SMP support: - driver_free_binary() - driver_realloc_binary() - driver_binary_get_refc() - driver_binary_inc_refc() - driver_binary_dec_refc()
| * | erts: Fix thread suspend in crashdumpBjörn-Egil Dahlberg2017-01-201-0/+3
| |/ | | | | | | * move signal handler setup
* | erts: Fix thread suspend in crashdumpBjörn-Egil Dahlberg2017-02-021-0/+3
| | | | | | | | * move signal handler setup
* | erts: Handle SIGUSR1 via signal service insteadBjörn-Egil Dahlberg2017-01-191-14/+0
| |
* | Merge branch 'maint'Sverker Eriksson2016-11-221-10/+11
|\ \ | |/
| * erts: Add ErtsStrToSint64Sverker Eriksson2016-11-171-0/+2
| | | | | | | | for simplify string to 64-bit integer parsing.