# Erts Release Notes

## Erts 5.1

### Fixed errors and malfunctions

- The call `trunc(F)` where `F` is a float such that the expected result is 2^27, instead returned -2^27. Also `round(134217727.5)` gave an erroneous answer.
  (Own Id: OTP-3722)
  (Aux Id: Seq 4925, OTP-3190)

- If the user suspended Erlang (e.g., by pressing ^Z), and the operating system is SunOS 2.6 or higher, trying to continue only resulted in Erlang being suspended again.
  (Own Id: OTP-3726)

- Deliverance of SIGCHLD signals to the emulator could fail when threads where used on Solaris. This could result in the (Solaris) process table being filled with defunct processes. Child process management in the emulator has been modified to eliminate this problem.
  (Own Id: OTP-3906)
  (Aux Id: Seq 5143, OTP-3963)

- A close of a tcp socket could be delayed up to 5 seconds after all pending output had been sent. Now the socket is closed immediately after all pending output has been sent.
  (Own Id: OTP-3924)
  (Aux Id: seq 5182, OTP-3963)

- When `demonitor/1` was used on a monitor for a process on another node (for example, using `gen_server` calls), not all associated allocated memory was freed, causing a memory leak of some 20 bytes each time. This has been fixed.
  (Own Id: OTP-3929)

- If `erlang:demonitor/1` was called in order to demonitor a process on another node, at the same time as the node went down, Erlang could sometimes crash. This has been fixed.
  (Own Id: OTP-3969)
  (Aux Id: seq5152)

- When constructing a binary, using a number of bits other than a multiple of 8 from a binary could give the wrong result in compiled code. Example: `B1 = <<73>>, B2 = <<0>>, <<B1:6/binary-unit:1,B2:2/binary-unit:1>>`.
  (Own Id: OTP-3995)

- The bor operator could return incorrect answer for big integers.
  (Own Id: OTP-4005)

- `binary_to_term` on binaries (for example `list_to_binary([131,111,255,255,255,0])` not corresponding to a term could crash Erlang.
  (Own Id: OTP-4053)

- When the system limit on maximal number of nodes known to a node had been reached (the distribution table had been filled), pids, ports, and references belonging to previously connected nodes could change node belonging. This bug has now been fixed. (Own Id: OTP-4071)
  (Aux Id: Seq-5311, OTP-4048)

- A bug in the heap fragment allocation could cause an emulator crash. This bug has now been fixed.
  (Own Id: OTP-4109)

- Emulator could crash due to exiting process monitoring process on a node that concurrently goes down. This has now been corrected.
  (Own Id: OTP-4112)
  (Aux Id: OTP-3969)

- A memory leak of 36 bytes per thread created, and a potential memory leak of 8 bytes per thread created have been fixed.
  (Own Id: OTP-4115)

- Miscalculation in gc could cause emulator crash. This has now been fixed.
  (Own Id: OTP-4116)

- An mmap leak in sl_alloc has been fixed.
  (Own Id: OTP-4120)

### Improvements and new features

- The driver interface (for writing Erlang drivers in C) is now documented. See the man page erl_driver in the ERTS documentation.

  The old driver.h include file has been moved to $(ERL_ROOT)/usr/include/obsolete. It is not recommended to use it, but if you need to use it, you must move it or change the include path to make sure that the C compiler can find it.

- The abstract format for representing Erlang code as Erlang terms is now documented, in the ERTS User's Guide.
  (Own Id: OTP-3039)

- A number of bug fixes and improvements have been done to applications `runtime_tools`, `kernel` and `erts`:
  - A read timeout no longer resets the sequential trace token. This is an incompatibility towards the previous behaviour. Use `seq_trace:set_token([])` to reset the sequential trace token.
  - `seq_trace:get_token/0` and `seq_trace:set_token/1` now have compatible token formats.
  - `dbg:trace_port/2` and `dbg:trace_client/2,3` now supports trace to and read from a size limited "wrap file set".
  - `dbg:trace_port_control/1` now supports operation `get_listen_port` for the ip trace driver.
  - New match spec functions `{is_seq_trace}` and `{get_seq_trace}` has been added to test and read the sequential trace token in match specs.
  - New match spec functions `{get_tcw}` and `{set_tcw Value}` that reads and sets a "trace control word" in the node has been added. The "trace control word" is a word in each Erlang node of at least 24 bits. There are also enhancements of BIFs: `erlang:system_info(trace_control_word)` and `erlang:system_flag(trace_control_word, Value)` for the same purpose.
  - A new match spec function `{silent, TrueOrFalse}` for setting a silent call trace flag per process that inhibits call trace messages, both local and global, has been added. The BIF `erlang:trace/3` has been extended to recognize the flag 'silent' to start a call trace in silent mode.
  - Some bugs in the `dbg` module has been fixed, e.g the 'old_trace_call' flag has been removed from the 'all' flags list, and the dbg server no longer hangs if the supplied tracer fails to start.
  - A bug in the emulator that made 'EXIT' messages from a process involved in a sequential call trace get overwritten by the sequential trace token itself has been fixed.
  - The documentation regarding the above has been updated. Especially, the fact that the match spec function `{return_trace}` destroys the tail recursiveness of the traced function has been pointed out.
  (*** POTENTIAL INCOMPATIBILITY ***)
  (Own Id: OTP-3747)
  (Aux Id: OTP-3592, OTP-3744)

- Hidden nodes and hidden global groups have been introduced. This makes it possible to establish hidden connections between Erlang nodes. See global_group(3), and erl(1).
  (Own Id: OTP-3916)
  (Aux Id: OTP-3963)

- The flag 'procs' to erlang:trace/3 has got a slightly new behaviour: Trace tag 'spawn' has a new element, and trace tags 'register', 'unregister', and 'getting_unlinked' are new. Therefore, new and/or different trace messages will arrive to the tracer when the 'procs' trace flag is used.
  (*** POTENTIAL INCOMPATIBILITY ***)
  (Own Id: OTP-3934)
  (Aux Id: seq5193)

- Wrap file traces now can limit the size of each file with a time instead of a size. See the documentation for dbg:trace_port/2.
  (Own Id: OTP-3935)
  (Aux Id: seq5193)

- When using trace flags 'running' and 'timestamp' to determine the amount of running time different processes in the system were using, the results were somewhat unreliable since the time to write the trace buffer itself randomly burdened the traced processes. This is now compensated for by faking process schedule out and in trace messages around the file writes (for the trace file driver trace_file_drv).
  (Own Id: OTP-3938)

- A new command line argument `-extra` has been introduced, which causes all following arguments to remain uninterpreted by Erlang; the arguments are included in the list returned by `init:get_plain_arguments/0`.
  (Own Id: OTP-3955)
  (Aux Id: OTP-3030, Seq 5203)

- dlmalloc was introduced in the Erlang emulator version 5.0.2.3 because it performed better than Solaris malloc when the emulator needed to allocate large short-lived memory blocks. It was later observed that it performed worse than Solaris malloc under some conditions. We have therefore now removed dlmalloc and replaced it with our own special treatment of short-lived memory blocks (called sl_alloc) and the standard malloc implementation for other blocks.

  The current version of sl_alloc uses the system call mmap() (on platforms where mmap() exists) in order to allocate large blocks (just as dlmalloc) and uses the standard malloc implementation for small blocks.

  Maximum number of mmapped blocks and the threshold which is used to determine if a block should be mmapped can be adjusted, see "System Flags" in erl(1).

  sl_alloc can be disabled. The standard malloc implementation will in this case be used instead, see "System Flags" in erl(1).
  (Own Id: OTP-4075)
  (Aux Id: SEQ-7057,)

- When the emulator runs without the async thread pool, large file read and write operations are now segmented into smaller, so that other Erlang processes can run in parallel. Still, a sync or a close operation on a large file may block the emulator as before. Using the async thread pool is the only cure for that.
  (Own Id: OTP-4144)

- In the Open-Source release of Erlang/OTP, the HiPE (High Performance Erlang) extension can be enabled. (Using `./configure --enable-hipe` when building.) If the runtime-system is hipe-enabled, a module can be native-code compiled like this:

  `c(Module, [native|OtherOptions])`.

  Compiling in this way, the beam file will contain both standard beam byte-code and the native code. If loaded on a hipe-enabled system the native code will be loaded; otherwise the beam-code will be loaded.

  HiPE is supported for Ultra Sparc and Intel Pentium.
  (Own Id: OTP-4153)

- Process termination when the process owns ETS tables is made considerably faster.
  (Own Id: OTP-4154)
  (Aux Id: OTP-3547)

- Due to the handling of the ETS name-to-table translations, a ets call when the named table did not exist could take considerable time before throwing "badarg". This is no longer the case.
  (Own Id: OTP-4155)
  (Aux Id: OTP-3547)

- The following new functions are added to the ets modules: ets:select/2 ets:select/3 ets:select/1 ets:match/3 ets:match/1 ets:match_object/3 ets:match_object/1 ets:member/2 ets:delete_all_objects/1 ets:delete_object/2 ets:from_dets/2 ets:to_dets/2 ets:test_ms/2 - See the ETS manual page for details. Furthermore the ets:insert/2 function now also accepts a list of objects to be inserted.
  (Own Id: OTP-4156)
  (Aux Id: OTP-3547)

- Ets:safe_fixtable/2 is made more efficient. Fixation is done without message passing and structures are held internally by the emulator.
  (Own Id: OTP-4157)
  (Aux Id: OTP-3547)

There are also release notes for older versions.