aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/erl_nif.c
AgeCommit message (Collapse)Author
2016-09-14Don't leak old code when loading a modules with an on_load functionBjörn Gustavsson
Normally, calling code:delete/1 before re-loading the code for a module is unnecessary but causes no problem. But there will be be problems if the new code has an on_load function. Code with an on_load function will always be loaded as old code to allowed it to be easily purged if the on_load function would fail. If the on_load function succeeds, the old and current code will be swapped. So in the scenario where code:delete/1 has been called explicitly, there is old code but no current code. Loading code with an on_load function will cause the reference to the old code to be overwritten. That will at best cause a memory leak, and at worst an emulator crash (especially if NIFs are involved). To avoid that situation, we will put the code with the on_load function in a special, third slot in Module. ERL-240
2016-09-09Merge branch 'maint'Rickard Green
* maint: Fix restore of 'current' field when rescheduled NIF completes
2016-09-09Fix restore of 'current' field when rescheduled NIF completesRickard Green
2016-08-31Merge branch 'maint'Rickard Green
* maint: Ensure correct mbuf_sz value in process structure
2016-08-30Ensure correct mbuf_sz value in process structureRickard Green
2016-08-29Merge branch 'maint'Rickard Green
* maint: Fix tracing of processes executing dirty Perform check_process_code while process is executing dirty Fix purge of code Reclaim literal area after purge has completed Separate literal area from code Conflicts: erts/emulator/beam/global.h
2016-08-29Merge branch 'rickard/ds-trace/OTP-13822' into maintRickard Green
* rickard/ds-trace/OTP-13822: Fix tracing of processes executing dirty
2016-08-29Fix tracing of processes executing dirtyRickard Green
2016-08-01erts: Refactor literal purge area argumentsBjörn-Egil Dahlberg
2016-08-01erts: Don't copy literals in enif_sendBjörn-Egil Dahlberg
2016-07-11erts: After a call to a tracer nif, reset htopLukas Larsson
This is needed in order for the heap to never contain any pointers to invalid memory. This is good for performance and debugging reasons.
2016-06-13erts: Allow enif_port_command in non-sched threadLukas Larsson
It has to be possible to send trace messages to a port from non-schedulers threads (specifically from the sys_msg_dispatcher).
2016-06-08Replace enif_is_on_dirty_scheduler() with enif_thread_type()Rickard Green
2016-06-01erts: Avoid literals in process independent ErlNifEnvSverker Eriksson
that would go undetected and cause havoc if module is purged.
2016-05-31Move dirty reduction count to erts_dirty_process_main()Rickard Green
2016-05-31Add dirty_process_main functionSteve Vinoski
Dirty schedulers only execute NIFs, so having them execute the full process_main function isn't necessary. Add dirty_process_main for dirty schedulers to execute instead. Add erts_pre_dirty_nif(), called when preparing to execute a dirty nif. Add more dirty NIF tests to verify that activities requiring the process main lock can succeed when the process is executing a dirty NIF.
2016-05-26Improve message allocation in enif_send()Rickard Green
2016-05-17Merge branch 'mikpe/otp-19-erts-integer-truncation-bugs/PR-1045/OTP-13606'Lukas Larsson
* mikpe/otp-19-erts-integer-truncation-bugs/PR-1045/OTP-13606: erl_unicode.c: fix integer truncation problems do not limit heap fragments to 4 giga-words erts_new_mso_binary(): do not truncate len Conflicts: erts/emulator/beam/erl_nif.c
2016-05-17erts: Fix bug when tracing in non-smp non-scheduler threadLukas Larsson
2016-05-13Merge branch 'egil/erts/nif-format_term/OTP-13580'Björn-Egil Dahlberg
* egil/erts/nif-format_term/OTP-13580: runtime_tools: Change erts_snprintf to enif_snprintf erts: Document enif_snprintf erts: Add tests for enif_snprintf erts: Add enif_snprintf Conflicts: erts/emulator/beam/erl_nif_api_funcs.h
2016-05-11Add better support for communication with a process executing dirty NIFRickard Green
- Termination of a process... - Modify trace flags of process... - Process info on process... - Register/unregister of name on process... - Set group leader on process... ... while it is executing a dirty NIF.
2016-05-11erts: Add enif_snprintfBjörn-Egil Dahlberg
* Add the capability to format erlang terms to a char buffer in nifs. * Bump NIF version to 2.11
2016-05-09Merge branch 'sverker/trace-send-receive-matchspec/OTP-13507'Sverker Eriksson
2016-05-05do not limit heap fragments to 4 giga-wordsMikael Pettersson
- struct erl_heap_fragment: use Uint for sizes - erl_nif.c: use size_t for sizes - erts_heap_frag_shrink(): remove now redundant cast
2016-05-04erts: Add Sender in 'receive' trace matchspecSverker Eriksson
All 'EXIT' and monitor messages are sent from 'system' Timeouts are "sent" from 'clock_service'
2016-05-04Reimplement -on_load()Björn Gustavsson
Load the module as old code; swap old and new code if the -on_load function succeeds. That way, a failed update attempt for a module that has an -on_load function will preserve the previous version of the code.
2016-04-29Merge branch 'egil/erts/tracing-support-lttng/OTP-13532'Björn-Egil Dahlberg
* egil/erts/tracing-support-lttng/OTP-13532: (28 commits) runtime_tools: User's guide to LTTng and dyntrace runtime_tools: Fix Dtrace build erts: Fix gc messages in tracer_SUITE erts: Fix gc messages in sensitive_SUITE erts: Fix gc messages in trace_port_SUITE tools: Update fprof tests tools: Update fprof with new gc traces runtime_tools: Update dyntrace_lttng_SUITE tests runtime_tools: Add 'return_to' for call tracing erts: Fix return_to trace callback erts: Update erl_tracer documentation erts: Fix erl_tracer documentation typos Update preloaded erl_tracer.beam erts: Update erl_tracer type specs runtime_tools: Add lttng dyntrace tests runtime_tools: Extend 'trace' and 'enabled' tracer callbacks erts: Extend 'enabled' and 'trace' tracer callbacks runtime_tools: Extend 'enabled' tracer callbacks erts: Extend 'enabled' tracer callbacks runtime_tools: Update lttng garbage collection trace ...
2016-04-22erts: Add BIF maps:take/2Björn-Egil Dahlberg
2016-04-19runtime_tools: Initial lttng tracing frameworkBjörn-Egil Dahlberg
2016-04-15erts: Deallocate heap fragments from trace nif callsLukas Larsson
Any heap fragment created during a nif call to a tracer nif should be free'd immediately in order for the GC not to treat it as live data.
2016-04-15erts: Fix FPE bug in erl_nifSverker Eriksson
erts_block/unblock_fpe should only be called at entry to/exit from native user code.
2016-04-15erts: Extend process and port tracingLukas Larsson
This commit completes the tracing for processes so that all messages sent by a process (via nifs or otherwise) will be traced. The commit also adds tracing of all types of events from ports. When enabling tracing using erlang:trace, the 'all' flag now also enables tracing on all ports. OTP-13496
2016-04-15erts: Implement tracer modulesLukas Larsson
Add the possibility to use modules as trace data receivers. The functions in the module have to be nifs as otherwise complex trace probes will be very hard to handle (complex means trace probes for ports for example). This commit changes the way that the ptab->tracer field works from always being an immediate, to now be NIL if no tracer is present or else be the tuple {TracerModule, TracerState} where TracerModule is an atom that is later used to lookup the appropriate tracer callbacks to call and TracerState is just passed to the tracer callback. The default process and port tracers have been rewritten to use the new API. This commit also changes the order which trace messages are delivered to the potential tracer process. Any enif_send done in a tracer module may be delayed indefinitely because of lock order issues. If a message is delayed any other trace message send from that process is also delayed so that order is preserved for each traced entity. This means that for some trace events (i.e. send/receive) the events may come in an unintuitive order (receive before send) to the trace receiver. Timestamps are taken when the trace message is generated so trace messages from differented processes may arrive with the timestamp out of order. Both the erlang:trace and seq_trace:set_system_tracer accept the new tracer module tracers and also the backwards compatible arguments. OTP-10267
2016-04-15erts: Add erts_nif_get_funcs and erts_nif_call_functionLukas Larsson
These are convinience functions for calling nifs from erts
2016-04-15Merge branch 'lukas/erts/enif_send_null_env/OTP-13495'Lukas Larsson
* lukas/erts/enif_send_null_env/OTP-13495: erts: Add enif_send with NULL as msg env
2016-04-13Merge branch 'henrik/update-copyrightyear'Henrik Nord
* henrik/update-copyrightyear: update copyright-year
2016-04-07erts: Add enif_send with NULL as msg envLukas Larsson
This is an optimization for reducing the number of heap fragments allocated when sending a message where the majority of the message payload is on the sending process' heap.
2016-03-29Merge branch 'lukas/erts/enif_trace_functions/OTP-13442'Lukas Larsson
* lukas/erts/enif_trace_functions/OTP-13442: erts: Fix bug in enif_send erts: Fix windows nif port tests erts: Fix bug in enif_term_to_binary erts: Remove printout when dec_term fails in DEBUG erts: Polish erl_nif docs erts: Improve enif_binary_to_term erts: Add enif_port_command erts: Add enif_term_to_binary and enif_binary_to_term erts: Add enif_is_process/port_alive erts: Add enif_cpu/now_time and enif_make_unique_integer
2016-03-29erts: Fix bug in enif_sendSverker Eriksson
Let cache_env() set env->heap_frag to same as MBUF(p) as it is in any other case.
2016-03-29erts: Fix bug in enif_term_to_binarySverker Eriksson
Wait until after dec_term and factory_close to do cache_env(), otherwise we will cache the wrong state.
2016-03-29erts: Improve enif_binary_to_termSverker Eriksson
* Accept a raw data buffer instead of ErlNifBinary * Accept option ERL_NIF_BIN2TERM_SAFE * Return number of read bytes
2016-03-29erts: Add enif_port_commandLukas Larsson
2016-03-29erts: Add enif_term_to_binary and enif_binary_to_termLukas Larsson
2016-03-29erts: Add enif_is_process/port_aliveLukas Larsson
2016-03-29erts: Add enif_cpu/now_time and enif_make_unique_integerLukas Larsson
2016-03-24Improve process/port specific data managementRickard Green
2016-03-15update copyright-yearHenrik Nord
2016-02-24Merge branch 'master' into sverk/master/halt-INT_MINSverker Eriksson
2016-02-24erts: Change erl_exit into erts_exitSverker Eriksson
This is mostly a pure refactoring. Except for the buggy cases when calling erlang:halt() with a positive integer in the range -(INT_MIN+2) to -INT_MIN that got confused with ERTS_ABORT_EXIT, ERTS_DUMP_EXIT and ERTS_INTR_EXIT. Outcome OLD erl_exit(n, ) NEW erts_exit(n, ) ------- ------------------- ------------------------------------------- exit(Status) n = -Status <= 0 n = Status >= 0 crashdump+abort n > 0, ignore n n = ERTS_ERROR_EXIT < 0 The outcome of the old ERTS_ABORT_EXIT, ERTS_INTR_EXIT and ERTS_DUMP_EXIT are the same as before (even though their values have changed).
2016-02-18Merge branch 'sverk/fix-list-length-int/OTP-13288'Sverker Eriksson
* sverk/fix-list-length-int/OTP-13288: erts: Fix error cases in enif_get_list_length erts: Use Sint instead of int for list lengths