aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/src/proc_lib.erl
AgeCommit message (Collapse)Author
2017-06-09stdlib: Handle Unicode atoms when formatting stacktracesHans Bolinder
2017-05-18kernel: Introcude error_logger:get_format_depth()Hans Bolinder
2017-05-18stdlib: Limit the size of proc_lib's crash reportsHans Bolinder
The size of the message queue and the dictionary is limited in crash reports. To avoid creating the potentially huge list of messages of the message queue, messages are received (if the Kernel variable error_logger_format_depth is set). The tag 'message_queue_len' has been added to the crash report.
2017-05-17proc_lib: Don't call erlang:get_stacktrace/0 twiceBjörn Gustavsson
proc_lib calls erlang:get_stacktrace/0 twice, which is unnecessary, and potentially unsafe since there are calls to many functions in between. Any of the calls could potentially cause and catch an exception, invalidating the stacktrace. Only call erlang:get_stacktrace/0 once, and pass the result to the second place where it is needed.
2016-10-31Propagate exceptions fully when using proc_libLoïc Hoguin
This makes proc_lib behaves like a normal process as far as the propagation of exceptions is concerned. Before this commit, the following difference could be observed: 6> spawn_link(fun() -> ssl:send(a,b) end). <0.43.0> 7> flush(). Shell got {'EXIT',<0.43.0>, {function_clause, [{ssl,send,[a,b],[{file,"..."},{line,275}]}]}} ok 8> proc_lib:spawn_link(fun() -> ssl:send(a,b) end). <0.46.0> 9> flush(). Shell got {'EXIT',<0.46.0>,function_clause} After this commit, we get the following instead: 3> flush(). Shell got {'EXIT',<0.61.0>, {function_clause, [{ssl,send,[a,b],[{file,"..."},{line,275}]}, {proc_lib,init_p,3,[{file,"..."},{line,232}]}]}} The stacktrace will show minor differences of course but the form is now the same as without proc_lib. The rationale behind this commit is that: * We now have a single form regardless of how the process was started * We can use the stacktrace to programmatically alter behavior (for example an HTTP server identifying problems in input decoding to send back a generic 400, or a 500 otherwise) * We can access the stacktrace to print it somewhere (for example an HTTP server could send it back to the client when a debug mode is enabled)
2016-05-25Relax translation of initial callsDan Gudmundsson
Remove the restriction to only do the translation for gen_server and gen_fsm. This enables user defined gen based generic callback modules to be displayed nicely in c:i() and observer.
2016-05-10erts: Implement max_heap_size process flagLukas Larsson
The max_heap_size process flag can be used to limit the growth of a process heap by killing it before it becomes too large to handle. It is possible to set the maximum using the `erl +hmax` option, `system_flag(max_heap_size, ...)`, `spawn_opt(Fun, [{max_heap_size, ...}])` and `process_flag(max_heap_size, ...)`. It is possible to configure the behaviour of the process when the maximum heap size is reached. The process may be sent an untrappable exit signal with reason kill and/or send an error_logger message with details on the process state. A new trace event called gc_max_heap_size is also triggered for the garbage_collection trace flag when the heap grows larger than the configured size. If kill and error_logger are disabled, it is still possible to see that the maximum has been reached by doing garbage collection tracing on the process. The heap size is defined as the sum of the heap memory that the process is currently using. This includes all generational heaps, the stack, any messages that are considered to be part of the heap and any extra memory the garbage collector may need during collection. In the current implementation this means that when a process is set using on_heap message queue data mode, the messages that are in the internal message queue are counted towards this value. For off_heap, only matched messages count towards the size of the heap. For mixed, it depends on race conditions within the VM whether a message is part of the heap or not. Below is an example run of the new behaviour: Eshell V8.0 (abort with ^G) 1> f(P),P = spawn_opt(fun() -> receive ok -> ok end end, [{max_heap_size, 512}]). <0.60.0> 2> erlang:trace(P, true, [garbage_collection, procs]). 1 3> [P ! lists:duplicate(M,M) || M <- lists:seq(1,15)],ok. ok 4> =ERROR REPORT==== 26-Apr-2016::16:25:10 === Process: <0.60.0> Context: maximum heap size reached Max heap size: 512 Total heap size: 723 Kill: true Error Logger: true GC Info: [{old_heap_block_size,0}, {heap_block_size,609}, {mbuf_size,145}, {recent_size,0}, {stack_size,9}, {old_heap_size,0}, {heap_size,211}, {bin_vheap_size,0}, {bin_vheap_block_size,46422}, {bin_old_vheap_size,0}, {bin_old_vheap_block_size,46422}] flush(). Shell got {trace,<0.60.0>,gc_start, [{old_heap_block_size,0}, {heap_block_size,233}, {mbuf_size,145}, {recent_size,0}, {stack_size,9}, {old_heap_size,0}, {heap_size,211}, {bin_vheap_size,0}, {bin_vheap_block_size,46422}, {bin_old_vheap_size,0}, {bin_old_vheap_block_size,46422}]} Shell got {trace,<0.60.0>,gc_max_heap_size, [{old_heap_block_size,0}, {heap_block_size,609}, {mbuf_size,145}, {recent_size,0}, {stack_size,9}, {old_heap_size,0}, {heap_size,211}, {bin_vheap_size,0}, {bin_vheap_block_size,46422}, {bin_old_vheap_size,0}, {bin_old_vheap_block_size,46422}]} Shell got {trace,<0.60.0>,exit,killed}
2016-04-26Fix proc_lib message_queue_data specLukas Larsson
2016-02-09New state machineRaimo Niskanen
2015-09-07proc_lib: Add format/3Björn Gustavsson
We'll need a way to limit the size of the crash report produced by proc_lib:format(). Add format/3, where the third argument is a depth argument.
2015-06-18Change license text to APLv2Bruce Yinhe
2014-08-21Merge branch 'maint'Björn-Egil Dahlberg
2014-07-11stdlib: Use erlang:fun_info_mfa/1 in proc_lib:init_p/3Björn-Egil Dahlberg
2014-05-26Add synchronous stop function to proc_libSiri Hansen
The new function utilizes sys:terminate.
2013-01-25Add a new function proc_lib:format/2 which takes encodingHans Bolinder
2012-10-30stdlib: Monitor proc_lib:start'ed processes to avoid waiting foreverDan Gudmundsson
Monitor the spawned process in proc_lib:start/[3|4|5], so that a proper error is returned, if the spawned process crashes before proclib:init_ack/1 is sent. Previously the calling process would hang forever or until specified timeout. Start link catches these errors but start did not. start now behaves as start_link if process traps exit.
2011-05-12Types and specifications have been modified and addedHans Bolinder
2010-06-04Merge branch 'ks/dialyzer' into devErlang/OTP
* ks/dialyzer: dialyzer: Build the PLT even if there are unresolved remote types proplists: Export the type property() erl_lint: Issue warnings for undefined exported types Minor fix in a print message Add handling of unknown types Add declaration for exported types Add types and specs; performed some cleanups also erl_scan: Add declarations for exported types stdlib: Add declarations for exported types hipe: Add declarations for exported types compiler: Add declarations for exported types syntax_tools: Add declarations for exported types kernel: Add declaration for exported types Support -export_type() in dialyzer and erl_types Add infrastructure for the -export_type() attribute OTP-8678 ks/dialyzer
2010-06-03stdlib: Add declarations for exported typesKostis Sagonas
2009-11-20The R13B03 release.OTP_R13B03Erlang/OTP