aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/test/nif_SUITE_data
AgeCommit message (Collapse)Author
2018-05-16erts: Fix bug in enif_binary_to_term for immediatesSverker Eriksson
Symptom: Heap corruption Expanded test case to provoke this bug and test some more term types.
2016-09-14erts: Add nif_SUITE:t_on_loadSverker Eriksson
2016-08-25Update test-cases to use new symbolic time unitsRickard Green
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-11erts: Add tests for enif_snprintfBjörn-Egil Dahlberg
2016-05-11Move dirty nif test cases into dirty_nif_SUITERickard Green
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-29erts: Fix windows nif port testsLukas Larsson
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-15update copyright-yearHenrik Nord
2016-03-11Remove ?line macrosBjörn-Egil Dahlberg
2016-03-11Eliminate use of ?config() macroBjörn-Egil Dahlberg
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
2016-02-17Eliminate use of test_server.hrl and test_server_line.hrlBjörn Gustavsson
As a first step to removing the test_server application as as its own separate application, change the inclusion of test_server.hrl to an inclusion of ct.hrl and remove the inclusion of test_server_line.hrl.
2016-02-08erts: Fix error cases in enif_get_list_lengthSverker Eriksson
false if improper list false if length > UINT_MAX
2016-01-21Introduce time management in native APIsRickard Green
2015-11-12erts: Fix nif_SUITE for win64Sverker Eriksson
where type long is only 32-bit and can not hold a pointer unless your lucky.
2015-06-18Change license text to APLv2Bruce Yinhe
2015-06-01Merge branch 'vinoski/enif-raise-exception/OTP-12770'Sverker Eriksson
* vinoski/enif-raise-exception/OTP-12770: Add enif_raise_exception Enhance enif_has_pending_exception Fix for enif_schedule_nif and exceptions Conflicts: erts/doc/src/erl_nif.xml
2015-05-27erts: Rename ErlNifMapIteratorEntry enumsSverker Eriksson
To differentiate between first/last map entry and head/tail which is before/after first/last map entry.
2015-05-26Add enif_raise_exceptionSteve Vinoski
Add enif_raise_exception function to allow NIFs to raise error exceptions holding any Erlang terms. This does not replace or deprecate the enif_make_badarg function, though, because raising badarg errors is so idiomatic in NIFs. Reimplement enif_make_badarg on top of enif_raise_exception. Add new tests for enif_raise_exception for both normal and dirty NIFs. Add documentation for enif_raise_exception.
2015-05-26Enhance enif_has_pending_exceptionSteve Vinoski
Sverker Eriksson came up with the following idea: to handle a future ability for NIFs to raise more than just badarg exceptions, modify the recently-added enif_has_pending_exception function to take a second argument: a pointer to ERL_NIF_TERM. If this argument is a null pointer, ignore it. Otherwise, if the first argument, an ErlNifEnv*, has an associated exception, set the pointed-to ERL_NIF_TERM of the second argument to the value of the exception term. Add new tests and documentation for this modification.
2015-05-26Fix for enif_schedule_nif and exceptionsSteve Vinoski
Fix a place where part of the implementation of enif_schedule_nif was not using the ErlNifEnv exception_thrown field when it should have been. Also make the result of enif_schedule_nif return false when passed to enif_is_exception, and add an assertion for this to the nif_SUITE.c tests.
2015-04-22Merge branch 'sverk/pr632/prevent-illegal-nif-terms/OTP-12655'Sverker Eriksson
* sverk/pr632/prevent-illegal-nif-terms/OTP-12655: erts: Reject non-finite float terms in erl_drv_output_term erts: Remove old docs about experimental NIF versions. erts: Add enif_has_pending_exception erts: Clearify erl_nif documentation about badarg exception erts: Fix compile warning in enif_make_double erts: Fix divide by zero compile error in nif_SUITE.c erts: Fix isfinite for windows Ensure NIF term creation disallows illegal values
2015-04-15erts: Add enif_has_pending_exceptionSverker Eriksson
2015-04-15erts: Fix divide by zero compile error in nif_SUITE.cSverker Eriksson
2015-03-19erts: Silence valgrind warning in nif_SUITE.cSverker Eriksson
Hmm, seems like gcc (4.4.3 at least) can switch the order of an &&-expression and do the last condition first if it think it's more efficient (and without side effects I hope). Which led to valgrind complaining about 'prev_ret' being used uninitialized in this case.
2015-03-15Ensure NIF term creation disallows illegal valuesSteve Vinoski
Add a check to enif_make_double to see if its double argument is infinity or NaN, returning a badarg exception if it is. Change the erl_nif documentation to specify that enif_make_double returns a badarg exception if its double argument is either infinity or NaN. Add tests to nif_SUITE for this change. Add checks to the enif_make* functions for atoms to prevent the creation of atoms whose name lengths are greater than the allowed maximum atom length. The enif_make_atom and enif_make_atom_len functions now return a badarg exception if the input string is too long. The enif_make_existing_atom and enif_make_existing_atom_len functions return false if the input string is too long. Change the erl_nif documentation to reflect the changes to these functions. Add tests to nif_SUITE for these changes. Add a field to ErlNifEnv to track that a NIF has raised an exception via enif_make_badarg. If a NIF calls enif_make_badarg but then ignores its return value and instead tries to return a non-exception term as its return value, the runtime still raises a badarg. This is needed to prevent enif_make_badarg values resulting from calls to enif_make_double, enif_make_atom, or enif_make_atom_len from being erroneously stored within other terms and returned from a NIF. Calling enif_make_badarg but not returning its return value has been documented as being illegal ever since enif_make_badarg was added, but the runtime has not enforced it until now. Add tests for regular and dirty NIFs to ensure that calls to enif_make_badarg result in badarg exceptions even if a NIF fails to return the result of enif_make_badarg as its return value. Add documentation to enif_make_badarg to specify that calling it raises a badarg even if a NIF ignores its return value.
2015-03-12erts: Fix nif API for hashmapsSverker Eriksson
2014-11-04Fix gc-related problem with dirty NIFsSteve Vinoski
Ensure that the return value from a dirty NIF call is made part of the GC rootset. Add a new regression test to nif_SUITE. Thanks to Daniel Goertzen for reporting the error and providing a test case, and to Sverker Eriksson for making test case reproducible and finding the fix.
2014-09-12erts: Remove enif_have_dirty_schedulers()Sverker Eriksson
and add 'dirty_scheduler_support' to ErlNifSysInfo
2014-09-04Merge branch 'sverk/nif-inspect-copy-bug/OTP-9828' into maintSverker Eriksson
* sverk/nif-inspect-copy-bug/OTP-9828: erts: Fix bug with enif_make_copy reallocating writable binary Conflicts: erts/emulator/test/nif_SUITE.erl
2014-09-03erts: Fix bug with enif_make_copy reallocating writable binarySverker Eriksson
that could invalidate a pointer received from an earlier call to enif_inspect_binary. Solution: Emasculate writable binary at enif_inspect_binary. There are room for optimizations here as we now do an unconditional emasculation even though enif_make_copy is not called later in the NIF.
2014-08-28add enif_schedule_nif() to NIF APISteve Vinoski
In the #erlang IRC channel Anthony Ramine once mentioned the idea of allowing a NIF to use an emulator trap, similar to a BIF trap, to schedule another NIF for execution. This is exactly how dirty NIFs were implemented for Erlang/OTP 17.0, so this commit refactors and generalizes that dirty NIF code to support a new enif_schedule_nif() API function. The enif_schedule_nif() function allows a long-running NIF to be broken into separate NIF invocations. The NIF first executes part of the long-running task, then calls enif_schedule_nif() to schedule a NIF for later execution to continue the task. Any number of NIFs can be scheduled in this manner, one after another. Since the emulator regains control between invocations, this helps avoid problems caused by native code tying up scheduler threads for too long. The enif_schedule_nif() function also replaces the original experimental dirty NIF API. The function takes a flags parameter that a caller can use to indicate the NIF should be scheduled onto either a dirty CPU scheduler thread, a dirty I/O scheduler thread, or scheduled as a regular NIF on a regular scheduler thread. With this change, the original experimental enif_schedule_dirty_nif(), enif_schedule_dirty_nif_finalizer() and enif_dirty_nif_finalizer() API functions are no longer needed and have been removed. Explicit scheduling of a dirty NIF finalization function is no longer necessary; if an application wants similar functionality, it can have a dirty NIF just invoke enif_schedule_nif() to schedule a non-dirty NIF to complete its task. Lift the restriction that dirty NIFs can't call enif_make_badarg() to raise an exception. This was a problem with the original dirty NIF API because it forced developers to get and check all incoming arguments in a regular NIF, and then schedule the dirty NIF which then had to get all the arguments again. Now, the argument checking can be done in the dirty NIF and it can call enif_make_badarg() itself to flag incorrect arguments. Extend the ErlNifFunc struct with a new flags field that allows NIFs to be declared as dirty. The default value for this field is 0, indicating a regular NIF, so it's backwards compatible with all existing statically initialized ErlNifFunc struct instances, and so such instances require no code changes. Defining the flags field with a value of ERL_NIF_DIRTY_JOB_CPU_BOUND indicates that the NIF should execute on a dirty CPU scheduler thread, or defining it with a value of ERL_NIF_DIRTY_JOB_IO_BOUND indicates that the NIF should execute on a dirty I/O scheduler thread. Any other flags field value causes a NIF library loading error. Extend the ErlNifEntry struct with a new options field that indicates whether a NIF library was built with support for optional features such as dirty NIFs. When a NIF library is loaded, the runtime checks the options field to ensure compatibility. If a NIF library built with dirty NIF support is loaded into a runtime that does not support dirty NIFs, and the library defines one or more ErlNifFunc entries with non-zero flags fields indicating dirty NIFs, a NIF library loading error results. There is no error if a NIF library built with dirty NIF support is loaded into a runtime that does not support dirty NIFs but the library does not have any dirty NIFs. It is also not an error if a library without dirty NIF support is loaded into a runtime built with dirty NIF support. Add documentation and tests for enif_schedule_nif().
2014-03-20Merge branch 'vinoski/ds-enif-send'Rickard Green
* vinoski/ds-enif-send: enable enif_send to work from a dirty scheduler
2014-03-10enable enif_send to work from a dirty schedulerSteve Vinoski
2014-02-28erts: Fix leak in nif_SUITE:resource_takeover (again)Sverker Eriksson
2014-02-20erts: Fix memory leak in nif_SUITE:resource_takeoverSverker Eriksson
2014-02-19Merge branch 'sverk/crypto/hmac-context-reuse-bug'Sverker Eriksson
OTP-11722 OTP-11724 * sverk/crypto/hmac-context-reuse-bug: crypto: Fix bug when using old hmac context erts: Fix NIF bug when load/upgrade fails after enif_open_resource_type Conflicts: erts/emulator/test/nif_SUITE.erl
2014-02-05erts: Fix NIF bug when load/upgrade fails after enif_open_resource_typeSverker Eriksson
..has been successfully called. Opened resource types (created or taken-over) were left "hanging" leading both to memory leakage and other more strange and serious behavior. Now a proper rollback is done.
2014-01-29erts: Change 'size' argument of enif_get_map_size from int* to size_t*Sverker Eriksson
2014-01-29erts: Add more tests for the NIF map APISverker Eriksson
2014-01-29erts: Fix map iterator bug when reverting from end of map positionSverker Eriksson
and simplify code by ignoring h_limit which is always zero.
2014-01-29erts: Test Maps with NIFsBjörn-Egil Dahlberg