Age | Commit message (Collapse) | Author |
|
|
|
when done by enif_free_env or enif_clear_env.
Do check before we free heap fragments.
|
|
|
|
The lack of this caused serious data corruption when a binary was
altered after entering the queue. This went unnoticed because it
was never used without erlang:iolist_to_iovec, which always
emasculates binaries.
|
|
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.
|
|
OTP-14520
|
|
|
|
* lukas/erts/fix_dirty_trace_message_flush/OTP-14538:
erts: Must have main lock when flushing trace messages
|
|
* sverker/enif_whereis-bug:
erts: Fix bug in enif_whereis_pid/port
|
|
that could cause heap corruption if
whereis lookup conflicts with other register updater
AND other thread sends on-heap message while main lock is released.
Also improved enif_whereis from dirty nifs by passing c_p as NULL.
|
|
* john/erts/runtime-lcnt:
Document rt_mask and add warnings about copy_save
Add an emulator test suite for lock counting
Break erts_debug:lock_counters/1 into separate BIFs
Allow toggling lock counting at runtime
Move lock flags to a common header
Enable register_SUITE for lcnt builds
Enable lcnt smoke test on all builds that have lcnt enabled
Make lock counter info independent of the locks being counted
OTP-14412
OTP-13170
OTP-14413
|
|
The implementation is still hidden behind ERTS_ENABLE_LOCK_COUNT, and
all categories are still enabled by default, but the actual counting can be
toggled at will.
OTP-13170
|
|
If we don't have the main lock, multiple threads may come in and
do the flush at the same time which will lead to all kinds of
strang problems.
|
|
#### Why do we need this new feature?
There are cases when a NIF needs to send a message, using `enif_send()`, to a long-lived process with a registered name.
A common use-case is logging, where asynchronous fire-and-forget messages are the norm.
There can also be cases where a yielding or dirty NIF or background thread may request a callback from a service with additional information it needs to complete its operation, yielding or waiting (with suitable timeouts, etc) until its state has been updated through the NIF module's API.
NIFs can only send messages to pids, and the lack of name resolution leaves a complicated dance between separate monitoring processes and the NIF as the only way to keep a NIF informed of the whereabouts of such long-lived processes.
Providing a reliable, built-in facility for NIFs to resolve process (or port) names simplifies these use cases considerably.
#### Risks or uncertain artifacts?
Testing has not exposed any significant risk.
The implementation behaves as expected on regular and dirty scheduler threads as well as non-scheduler threads.
By constraining the `enif_whereis_...()` functions to their minimal scopes and using patterns consistent with related functions, the implementation, testing, and maintenance burden is low.
The API and behavior of existing functions is unchanged.
#### How did you solve it?
While extending `enif_send()` to operate on a pid or an atom (as `erlang:send/2` does) was attractive, it would have entailed changing the type of its `to_pid` parameter and thereby breaking backward compatibility.
The same consideration applies to `enif_port_command()`.
That leaves a choice between 1, 2, or 3 new functions:
1. `enif_whereis()`
2. `enif_whereis_pid()` and `enif_whereis_port()`
3. All of the above.
While option (1), directly mimicking the behavior of `erlang:whereis/1`, is appealing, it poses potential problems if `pid()` or `port()` are subsequently implemented as non-integral types that must be bound to an owning `ErlNifEnv` instance.
Therefore, option (2) has been chosen to use `ErlNifPid`/`ErlNifPort` structures in the API to maintain proper term ownership semantics.
|
|
|
|
Support hashing terms from NIF code
|
|
* sverker/refactor:
erts: Introduce struct binary_internals
erts: Introduce erts_bin_release
erts: Init refc=1 in erts_bin_drv_alloc*
erts: Init refc=1 in erts_bin_nrml_alloc
erts: Remove deliberate leak of hipe fun entries
erts: Remove hipe_bifs:remove_refs_from/1
Refactor hipe specific code to use ErtsCodeInfo
erts: Refactor ErtsCodeInfo.native
|
|
|
|
Allow for expanding support to 64-bit hashes without breaking the
interface.
|
|
|
|
A more generic hashing function which can also hash terms based on
`make_internal_hash'.
|
|
|
|
These allow one to hash VM terms from NIF code.
|
|
to replace macro ERTS_INTERNAL_BINARY_FIELDS
as header in Binary and friends.
|
|
* rickard/sched_type_tests:
Fix dirty scheduler type tests
|
|
|
|
|
|
into union with actual usage types.
|
|
Old test for dirty schedulers didn't work with Visual C++
|
|
|
|
|
|
|
|
Conflicts:
erts/emulator/beam/erl_binary.h
erts/emulator/beam/erl_monitors.c
erts/emulator/beam/erl_nif.c
erts/emulator/beam/global.h
erts/emulator/test/nif_SUITE_data/nif_SUITE.c
|
|
# Conflicts:
# erts/emulator/test/nif_SUITE_data/nif_SUITE.c
|
|
|
|
* sverker/enif_send-noproc-fix:
erts: Fix enif_send from noproc and no msg_env
|
|
A magic destructor can return 0 and thereby take control
and prolong the lifetime of a magic binary.
|
|
|
|
|
|
|
|
Magic references are *intentionally* indistinguishable from ordinary
references for the Erlang software. Magic references do not change
the language, and are intended as a pure runtime internal optimization.
An ordinary reference is typically used as a key in some table. A
magic reference has a direct pointer to a reference counted magic
binary. This makes it possible to implement various things without
having to do lookups in a table, but instead access the data directly.
Besides very fast lookups this can also improve scalability by
removing a potentially contended table. A couple of examples of
planned future usage of magic references are ETS table identifiers,
and BIF timer identifiers.
Besides future optimizations using magic references it should also
be possible to replace the exposed magic binary cludge with magic
references. That is, magic binaries that are exposed as empty
binaries to the Erlang software.
|
|
as it's not part of the API
|
|
A magic destructor can return 0 and thereby take control
and prolong the lifetime of a magic binary.
|
|
|
|
* rickard/ds-20-fix:
Fix unused warning
Change exception for enif_schedule_nif() with dirty flags
Remove double check of NifExport when checking process code
|
|
* sverker/ASSERT_IN_ENV:
erts: Add macro ERTS_PROC_LOCKS_HIGHER_THAN
erts: Cleanup and extra assertions in nif_SUITE.c
erts: Cleanup enif_make_reverse_list
erts: Add assertions for correct ErlNifEnv
erts: Make erts_dbg_within_proc available
# Conflicts:
# erts/emulator/beam/erl_gc.h
|
|
|
|
|
|
Only try direct allocation on receiver heap when called
in a real process context to avoid trylock on our own main lock.
|
|
|