summaryrefslogtreecommitdiff
path: root/erts/emulator/test/exception_SUITE.erl
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'maint'Sverker Eriksson2022-10-051-7/+2
|\
| * erts: Improve node leak check in end_per_testcaseSverker Eriksson2022-10-041-7/+2
| | | | | | | | | | Don't lose original failure reason, instead amend "Leaked connections".
* | erts: Implement erlang:display_string/2 used for testingLukas Larsson2022-08-291-0/+2
|/
* erts: Check for leaking peer nodes after testsSverker Eriksson2022-08-161-0/+11
|
* Merge branch 'rickard/global-fixes/24.3.3/OTP-17934' into ↵Rickard Green2022-05-251-1/+15
|\ | | | | | | | | | | | | | | | | | | | | | | | | rickard/global-fixes/25.0/OTP-17934 * rickard/global-fixes/24.3.3/OTP-17934: [kernel] Introduce connect_all kernel parameter [kernel] global fixes [kernel] Monitor nodeup/nodedown directly from global [kernel] Fix global group configuration [erts,kernel] Connection ID information kernel: Fix test case monitor_nodess_down_up Guarantee nodedown before nodeup messages
| * Merge branch 'rickard/global-fixes/23.3.4/OTP-17934' into ↵Rickard Green2022-05-251-1/+15
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | rickard/global-fixes/24.3.3/OTP-17934 * rickard/global-fixes/23.3.4/OTP-17934: [kernel] Introduce connect_all kernel parameter [kernel] global fixes [kernel] Monitor nodeup/nodedown directly from global [kernel] Fix global group configuration [erts,kernel] Connection ID information kernel: Fix test case monitor_nodess_down_up Guarantee nodedown before nodeup messages
* | | jit: Fix wonky line numbersJohn Högberg2022-05-051-0/+17
| | |
* | | Update copyright yearErlang/OTP2022-02-151-1/+1
| | |
* | | Provide more information for failed record operationsBjörn Gustavsson2022-02-091-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a record operation fails, a `{badrecord,Tag}` error exception is raised, where `Tag` is the name of the record. For example, if we have this function: -record(foo, {a,b,c,d}). bar(R) -> R#foo.a. we will get the following exception if we call `bar/1` with something else than a #foo{} record: 1> t:bar({x,y,z}). ** exception error: {badrecord,foo} in function t:bar/1 (t.erl, line 7) When records were first introduced, there were no line numbers in exceptions, so if a record operation failed in a large function knowing the record name could be useful. Nowadays, the line number usually makes it obvious which kind of record the failed operation expected. It would be more useful to know the actual value passed to the record operation. This commit changes the exception for a failed record operation to `{badrecord,ActualValue}`. For example: 1> t:bar({x,y,z}). ** exception error: {badrecord,{x,y,z}} in function t:bar/1 (t.erl, line 7) 2> t:bar(lists:seq(1, 1000)). ** exception error: {badrecord,[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19, 20,21,22,23,24,25,26,27|...]} in function t:bar/1 (t.erl, line 7) Note that it is not documented what the exception for a failed record operation is supposed to look like. Furthermore, it is unlikely that there is exisiting code that catches expressions involving records operations and tries to match the exact error reason. Therefore, we don't consider this an incompatible change.
* | | Fix typos in erts/emulator/testKian-Meng, Ang2021-12-021-1/+1
| | |
* | | Merge branch 'maint'Björn Gustavsson2021-11-261-0/+6
|\ \ \ | |/ / | | | | | | | | | * maint: Fix test case that started to fail because of bf115ee06a90a7d9a
| * | Fix test case that started to fail because of bf115ee06a90a7d9aBjörn Gustavsson2021-11-261-0/+6
| | |
* | | Merge branch 'maint'Lukas Larsson2021-11-251-0/+1
|\ \ \ | |/ /
| * | erts: Fix open_port({spawn,"a"},[{args,[]}]) error infoLukas Larsson2021-11-171-0/+1
| | | | | | | | | | | | | | | | | | Before this fix the error reason would be "invalid port name", which is true but not as helpfull as it could be. So now it returns "must be spawn_executable".
* | | emulator: replace test_server:start node with ?CT_PEERMaxim Fedorov2021-11-081-2/+2
| | | | | | | | | | | | | | | | | | | | | Cleanup emulator application, sweep duplicate code that was adding code path to the test suite module, make peer node naming uniform, protect from rogue nodes left when test case fails.
* | | Merge pull request #5281 from bjorng/bjorn/bs-construction/GH-4971/OTP-17504Björn Gustavsson2021-10-221-6/+5
|\ \ \ | | | | | | | | Implement extended error information for binary construction
| * | | Implement the bs_create_bin instructionBjörn Gustavsson2021-10-191-6/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implement the bs_create_bin instruction for the JITs and the emulator. Consider this example module: -module(foo). -export([bin/2, int/2, float/2, var_int/2]). bin(A, B) -> <<A/binary, B/binary>>. int(A, B) -> <<A/integer, B/integer>>. float(A, B) -> <<A/float, B/float>>. var_int(A, Size) -> <<A:Size>>. With the extended error information introduced in this commit, failures to build binaries will be reported like this: 1> c(foo). {ok,foo} 2> foo:bin(2, <<>>). ** exception error: construction of binary failed in function foo:bin/2 (foo.erl, line 4) *** segment 1 of type 'binary': expected a binary but got: 2 3> foo:bin(<<>>, 42). ** exception error: construction of binary failed in function foo:bin/2 (foo.erl, line 4) *** segment 2 of type 'binary': expected a binary but got: 42 4> foo:bin(<<>>, <<1:1>>). ** exception error: construction of binary failed in function foo:bin/2 (foo.erl, line 4) *** segment 2 of type 'binary': the size of the value <<1:1>> is not a multiple of the unit for the segment 5> foo:int(a, 42). ** exception error: construction of binary failed in function foo:int/2 (foo.erl, line 5) *** segment 1 of type 'integer': expected an integer but got: a 6> foo:float(<<>>, <<>>). ** exception error: construction of binary failed in function foo:float/2 (foo.erl, line 6) *** segment 1 of type 'float': expected a float or an integer but got: <<>> 7> foo:var_int(42, -1). ** exception error: construction of binary failed in function foo:var_int/2 (foo.erl, line 7) *** segment 1 of type 'integer': expected a non-negative integer as size but got: -1 8> foo:var_int(42, a). ** exception error: construction of binary failed in function foo:var_int/2 (foo.erl, line 7) *** segment 1 of type 'integer': expected a non-negative integer as size but got: a 9> foo:var_int(42, 1 bsl 64). ** exception error: construction of binary failed in function foo:var_int/2 (foo.erl, line 7) *** segment 1 of type 'integer': the size 18446744073709551616 is too large Closes #4971.
* | | | Merge branch 'maint'John Högberg2021-10-191-3/+3
|\ \ \ \ | | |/ / | |/| | | | | | | | | | * maint: erts: Fix testcase in previous commit
| * | | erts: Fix testcase in previous commitJohn Högberg2021-10-191-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The test could not be loaded on 32-bit machines because the line number wouldn't fit a signed word, so we'll lower it to a point where it can be loaded. We'll settle for this instead of fixing loading on 32-bit since trying to load files with absurd line numbers is extremely contrived.
* | | | Merge branch 'maint'John Högberg2021-10-151-0/+12
|\ \ \ \ | |/ / / | | / / | |/ / |/| | * maint: erts: Fix crash on exceptions with huge line numbers
| * | erts: Fix crash on exceptions with huge line numbersJohn Högberg2021-10-141-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | Unrepresentable locations should be ignored, but I forgot to bring that over when rewriting the loader in OTP 24. To prevent something like this from happening again, ignore them in the MAKE_LOCATION macro rather than around each use.
* | | Merge branch 'maint'Björn Gustavsson2021-09-011-3/+10
|\ \ \ | |/ / | | | | | | | | | * maint: Correct extended error for binary_to_term/2
| * | Correct extended error for binary_to_term/2Björn Gustavsson2021-08-311-3/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When `binary_to_term/2` failed with a `badarg` exception, the extended error information would always blame the second argument even if the error was in the first argument: 1> binary_to_term(<<"">>, []). ** exception error: bad argument in function binary_to_term/2 called as binary_to_term(<<>>,[]) *** argument 2: invalid option in list 2> binary_to_term(<<131,100,0,10,97,95,110,101,119,95,97,116,111,109>>, [safe]). ** exception error: bad argument in function binary_to_term/2 called as binary_to_term(<<131,100,0,10,97,95,110,101,119,95,97,116,111,109>>, [safe]) *** argument 2: invalid option in list Correct the extended error information like this: 1> binary_to_term(<<"">>, []). ** exception error: bad argument in function binary_to_term/2 called as binary_to_term(<<>>,[]) *** argument 1: invalid external representation of a term 2> binary_to_term(<<131,100,0,10,97,95,110,101,119,95,97,116,111,109>>, [safe]). ** exception error: bad argument in function binary_to_term/2 called as binary_to_term(<<131,100,0,10,97,95,110,101,119,95,97,116,111,109>>, [safe]) *** argument 1: invalid or unsafe external representation of a term Closes #5171.
* | | Merge branch 'maint'Raimo Niskanen2021-08-181-2/+5
|\ \ \ | |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * maint: Update preloaded Test differing cookies with dynamic node names Implement set_cookie/1 and get_cookie/1 Clarify documentation of cookie handling Clean up handshake Cookie handling Test command line -setcookie Node Cookie Read other nodes' cookies from command line Read other nodes' cookies from command line Test differing cookies
| * | Implement set_cookie/1 and get_cookie/1Raimo Niskanen2021-08-161-2/+5
| | | | | | | | | | | | Clarify the documentation further regarding to these functions.
* | | Merge branch 'maint'Björn Gustavsson2021-05-311-0/+12
|\ \ \ | |/ / | | | | | | | | | * maint: Correct error messages for timer BIFs
| * | Merge pull request #4906 from bjorng/bjorn/fix-timer-bif-errors/OTP-17449Björn Gustavsson2021-05-311-0/+12
| |\ \ | | | | | | | | Correct error messages for timer BIFs
| | * | Correct error messages for timer BIFsBjörn Gustavsson2021-05-281-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The extended error information for timer BIFs would be incorrect if a time value that exceeded the maximum allowed value was given: 1> erlang:send_after(1 bsl 50, self(), whatever). ** exception error: bad argument in function erlang:send_after/3 called as erlang:send_after(1125899906842624,<0.83.0>,whatever) 2> erlang:send_after(1 bsl 50, self(), whatever, []). ** exception error: bad argument in function erlang:send_after/4 called as erlang:send_after(1125899906842624,<0.85.0>,whatever,[]) *** argument 4: invalid option in list For the call to `erlang:send_after/3`, no extended errors information would be reported, while for the call to `erlang:send_after/4` there would be an incorrect error message for the fourth argument. This commit correct the messages, producing: 1> erlang:send_after(1 bsl 50, self(), whatever). ** exception error: bad argument in function erlang:send_after/3 called as erlang:send_after(1125899906842624,<0.83.0>,whatever) *** argument 1: exceeds the maximum supported time value 2> erlang:send_after(1 bsl 50, self(), whatever, []). ** exception error: bad argument in function erlang:send_after/4 called as erlang:send_after(1125899906842624,<0.85.0>,whatever,[]) *** argument 1: exceeds the maximum supported time value
* | | | Merge branch 'maint'Björn Gustavsson2021-05-281-0/+2
|\ \ \ \ | |/ / / | | | | | | | | | | | | | | | | * maint: Correct error message for binary_to_existing_atom/2 Eliminate incorrect warning for useless building
| * | | Merge pull request #4901 from bjorng/bjorn/fix-error-info/GH-4900/OTP-17449Björn Gustavsson2021-05-281-0/+2
| |\ \ \ | | |/ / | |/| | Correct error message for binary_to_existing_atom/2
| | * | Correct error message for binary_to_existing_atom/2Björn Gustavsson2021-05-271-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The extended error information for `binary_to_existing_atom/2` was wrong when the encoding was `utf8` or `unicode`: 1> binary_to_existing_atom(<<"oops doesnt_really_exist">>, utf8). ** exception error: bad argument in function binary_to_existing_atom/2 called as binary_to_existing_atom(<<"oops doesnt_really_exist">>,utf8) *** argument 1: invalid UTF8 encoding Corrected: 1> binary_to_existing_atom(<<"oops doesnt_really_exist">>, utf8). ** exception error: bad argument in function binary_to_existing_atom/2 called as binary_to_existing_atom(<<"oops doesnt_really_exist">>,utf8) *** argument 1: not an already existing atom Also fixed a similar problem for `list_to_existing_atom/1`. Closes #4900.
* | | | Merge branch 'maint'Lukas Larsson2021-05-271-1/+7
|\ \ \ \ | |/ / /
| * | | erts: Expand error/2,3 to take none as argumentLukas Larsson2021-05-171-1/+7
| |/ / | | | | | | | | | | | | | | | This has always been possible, we just document that it should work this way if you want to raise an error using the arity of the calling function.
* | | Allow stacktrace variation in exception test casesBjörn Gustavsson2021-05-241-13/+40
|/ / | | | | | | | | | | | | The JIT for ARM will give a more detailed stacktrace for operators such as '+'/2 (the top stacktrace entry will be for the operator including its arguments). Update test cases that test for exceptions to allow for this variation.
* | Correct extended error info for remote pids and portsBjörn Gustavsson2021-04-231-4/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For BIFs that only accept a local pid, the extended error information would state that the argument was not a pid. For example: (arne@seldon)1> RemotePid = rpc:call(kalle@seldon, erlang, whereis, [code_server]). <9325.50.0> (arne@seldon)2> process_info(RemotePid). ** exception error: bad argument in function process_info/1 called as process_info(<9325.50.0>) *** argument 1: not a pid Correct the extended error information for those BIFs to report the argument as "not a local pid". For example: (arne@seldon)1> RemotePid = rpc:call(kalle@seldon, erlang, whereis, [code_server]). <9325.50.0> (arne@seldon)2> process_info(RemotePid). ** exception error: bad argument in function process_info/1 called as process_info(<9325.50.0>) *** argument 1: not a local pid Similarly, the extended error information for BIFs that operate on ports (such as `port_control/3`) would state that a remote port was not a port.
* | erlang:memory/1: Correct error handling and error reportingBjörn Gustavsson2021-01-141-3/+11
| |
* | erlang: Add extended error for all BIFsBjörn Gustavsson2020-12-141-12/+171
| |
* | Implement EEP-54 (extended error information)Björn Gustavsson2020-12-021-4/+504
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit is the reference implementation for EEP-54, which proposes a mechanism for providing more informational messages than simply "bad argument" when a call to a BIF fails. Here is an example: 1> element(a, b). ** exception error: bad argument in function element/2 called as element(a,b) *** argument 1: not an integer *** argument 2: not a tuple All the details are found in EEP-54, but here are the main points: * An extension of the format of the call-stack back trace (**stacktrace**) format to indicate that there exists extended error information for that call, and a convention for how extended error information can be provided. * A new `erlang:error/3` BIF to allow libraries and applications to raise an exception with extended error information. * New functions `erl_error:format_exception/3` and `erl_error:format_exception/4` to allow libraries and application to format stacktraces in the same style as the shell. This implementation of EEP-54 implements extended error information for all C-implemented BIFs in the `erlang` and `ets` modules.
* | otp: Remove HiPE and HiPE-related accessoriesJohn Högberg2020-11-091-4/+0
| |
* | jit: Handle modules without line numbersBjörn Gustavsson2020-10-151-2/+18
| |
* | jit: Further polish and optimize BEAMASMBjörn Gustavsson2020-09-221-1/+32
| | | | | | | | | | | | Co-authored-by: Lukas Larsson <lukas@erlang.org> Co-authored-by: John Högberg <john@erlang.org> Co-authored-by: Dan Gudmundsson <dgud@erlang.org>
* | Merge branch 'maint'Björn Gustavsson2020-06-111-0/+12
|\ \ | |/ | | | | | | | | | | * maint: Fix filelib:wildcard/1,2 for "not-a-directory/.." Eliminate compiler crash for repeated is_map_key/2 calls Fix line number for failing map update
| * Fix line number for failing map updateBjörn Gustavsson2020-06-041-0/+12
| | | | | | | | | | | | | | If the update of a map using the syntax `Map#{Key := Value}` failed, the line number in the stack backtrace could be wrong. https://bugs.erlang.org/browse/ERL-1271
* | Remove the deprecated erlang:get_stacktrace/0 functionBjörn Gustavsson2020-05-151-3/+0
|/ | | | `erlang:get_stacktrace/0` was deprecated in OTP 20.
* Merge branch 'maint'Rickard Green2020-03-131-1/+1
|\ | | | | | | | | * maint: Update copyright year
| * Update copyright yearRickard Green2020-03-131-1/+1
| |
* | Don't keep stacktraces foreverBjörn Gustavsson2020-02-211-79/+59
|/ | | | | | | | | | | | | | | | | The `erlang:get_stacktrace/0` BIF retrieves the stacktrace from the previous error in the process. The problem is that the very existence of `erlang:get_stacktrace/0` means that the stacktrace and potentially function arguments must be kept indefinitely. Therefore, in OTP 21, the `erlang:get_stacktrace/0` BIF was deprecated and the syntax of try/catch extended to allow matching out the stacktrace directly. This commit changes `erlang:get_stacktrace/0` for OTP 23 to always return an empty list (`[]`) and eliminates the need to keep the stacktrace forever. `erlang:get_stacktrace/0` is scheduled for removal in OTP 24.
* Merge branch 'bjorn/erts/fix-wrong-class/ERIERL-367/OTP-15834' into maintBjörn Gustavsson2019-05-241-0/+34
|\ | | | | | | | | * bjorn/erts/fix-wrong-class/ERIERL-367/OTP-15834: Fix sticky class in exception
| * Fix sticky class in exceptionBjörn Gustavsson2019-05-231-0/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When catching an exception re-throwing with a changed class, the class could be changed to the original class if the exception got caught and rethrown in (for example) an after block: sticky_class() -> try try throw(reason) catch throw:Reason:Stack -> erlang:raise(error, Reason, Stack) end after ok end.
* | compiler: Introduce module-level type optimizationJohn Högberg2019-01-241-0/+5
|/ | | | | This commit lets the type optimization pass work across functions, tracking return and argument types to eliminate redundant tests.