Age | Commit message (Collapse) | Author |
|
When using the async thread pool, if an erlang process
asks to open a file and it gets shutdown/killed while
the file:open/2 call hasn't returned, it's possible to
leak a file descriptor against the target file.
This happens because when the file driver is stopped
(file_stop() function is called), an async thread is
executing, about to execute, or executed already the
invoke_open() function. After file_stop() is called,
the file_async_ready() function will not run, and this
function is responsible for setting desc->fd with the
file descriptor that invoke_open() got. The file_stop()
call closes desc->fd if it refers to a valid file
descriptor, which is not the case here, because this
function was called before file_async_ready() could
run.
This leak is easily reproducile in a GNU/Linux system
using the following test code:
-module(t).
-export([t/1]).
t(N) ->
Pid = spawn_link(fun() ->
process_flag(trap_exit, true),
loop(N)
end),
Ref = erlang:monitor(process, Pid),
receive {'DOWN', Ref, _, _, _} ->
ok
end.
loop(0) ->
ok;
loop(N) ->
Name = integer_to_list(N),
Server = self(),
Pid = spawn(fun() ->
Server ! continue,
{ok, FdW} = file:open(Name, [raw, write]),
{ok, FdR} = file:open(Name, [raw, read]),
% Optional close calls, with or without them
% it makes no difference.
%ok = file:close(FdW),
%ok = file:close(FdR),
ok
end),
receive continue -> ok end,
exit(Pid, shutdown),
loop(N - 1).
Running this code with a few iterations is enough to very often
notice, with the lsof command, that the beam.smp process is holding
forever file descriptors open. This issue doesn't happen if the
async thread pool is not used.
Example:
$ erl +A 4
Erlang R15B03 (erts-5.9.3) [source] [64-bit] [smp:4:4] [async-threads:4] [hipe] [kernel-poll:false]
Eshell V5.9.3 (abort with ^G)
1> c(t).
{ok,t}
2> os:getpid().
"31975"
3> t:t(20).
ok
In a separate shell:
$ lsof -p 31975
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
beam.smp 31975 fdmanana cwd DIR 8,18 22736896 32563204 /home/fdmanana/git/hub/otp/tmp
beam.smp 31975 fdmanana rtd DIR 8,1 4096 2 /
beam.smp 31975 fdmanana txt REG 8,1 7600263 1835126 /opt/r15b03/lib/erlang/erts-5.9.3/bin/beam.smp
beam.smp 31975 fdmanana mem REG 8,1 7220736 2497283 /usr/lib/locale/locale-archive
beam.smp 31975 fdmanana mem REG 8,1 10280 2505021 /usr/lib/libsctp.so.1.0.11
beam.smp 31975 fdmanana mem REG 8,1 1811128 917795 /lib/x86_64-linux-gnu/libc-2.15.so
beam.smp 31975 fdmanana mem REG 8,1 31752 917803 /lib/x86_64-linux-gnu/librt-2.15.so
beam.smp 31975 fdmanana mem REG 8,1 135366 917799 /lib/x86_64-linux-gnu/libpthread-2.15.so
beam.smp 31975 fdmanana mem REG 8,1 159200 921249 /lib/x86_64-linux-gnu/libtinfo.so.5.9
beam.smp 31975 fdmanana mem REG 8,1 1030512 917962 /lib/x86_64-linux-gnu/libm-2.15.so
beam.smp 31975 fdmanana mem REG 8,1 14768 917702 /lib/x86_64-linux-gnu/libdl-2.15.so
beam.smp 31975 fdmanana mem REG 8,1 149280 917974 /lib/x86_64-linux-gnu/ld-2.15.so
beam.smp 31975 fdmanana 0u CHR 136,1 4 /dev/pts/1
beam.smp 31975 fdmanana 1u CHR 136,1 4 /dev/pts/1
beam.smp 31975 fdmanana 2u CHR 136,1 4 /dev/pts/1
beam.smp 31975 fdmanana 3r FIFO 0,8 1298297 pipe
beam.smp 31975 fdmanana 4w FIFO 0,8 1298297 pipe
beam.smp 31975 fdmanana 5r FIFO 0,8 1298298 pipe
beam.smp 31975 fdmanana 6w FIFO 0,8 1298298 pipe
beam.smp 31975 fdmanana 7w REG 8,18 0 32564173 /home/fdmanana/git/hub/otp/tmp/20
beam.smp 31975 fdmanana 8w REG 8,18 0 32564176 /home/fdmanana/git/hub/otp/tmp/16
beam.smp 31975 fdmanana 9w REG 8,18 0 32564177 /home/fdmanana/git/hub/otp/tmp/15
beam.smp 31975 fdmanana 10w REG 8,18 0 32564179 /home/fdmanana/git/hub/otp/tmp/12
beam.smp 31975 fdmanana 11w REG 8,18 0 32564180 /home/fdmanana/git/hub/otp/tmp/11
beam.smp 31975 fdmanana 12w REG 8,18 0 32564205 /home/fdmanana/git/hub/otp/tmp/10
beam.smp 31975 fdmanana 13w REG 8,18 0 32564182 /home/fdmanana/git/hub/otp/tmp/8
beam.smp 31975 fdmanana 14w REG 8,18 0 32564183 /home/fdmanana/git/hub/otp/tmp/7
beam.smp 31975 fdmanana 15w REG 8,18 0 32564186 /home/fdmanana/git/hub/otp/tmp/3
|
|
|
|
* hb/prepare_for_unicode/OTP-10630:
Prepare OTP files for Unicode as default encoding
|
|
|
|
* siri/cover/new-bugs-r16/OTP-10638:
[cover] Cleanup by stopping cover between tests
[common_test] Stop cover on slave node after node is terminated
[test_server] Stop cover on node after node is terminated
[cover] Fix timing dependent bug in cover_SUITE:reconnect
[cover] Remove stopped node also from lost_nodes list
[cover] Don't mark stopped node as lost
|
|
* hb/fix_fop_warnings/OTP-10665:
Fix some FOP warnings
|
|
Examples overflowing the width of PDF pages have been fixed.
The remaining warnings are due to table cells, and require more
work.
|
|
* sverk/hipe-smp-independence:
erts,hipe: Make hipe compiler ask running emulator about process struct offsets
|
|
* ia/ssl/TLS-1.2-default/OTP-10425:
ssl: Make TLS-1.2 default version
|
|
* ia/ssl/deprecated-r16:
stdlib: Updated otp_internal to reflect removal of deprecated function
ssl & orber: Remove ssl:pid/1 (has been pointless since R14)
|
|
* hb/stdlib/shell_improvement/OTP-10659:
[stdlib] Improve the Erlang shell's handling of scanner errors
|
|
The Erlang shell now skips the rest of the line when
it encounters an Erlang scanner error.
Examples:
1> $\xtt.
* 1: illegal character
1> "$\xtt".
* 1: illegal character
1>
|
|
* ks/stdlib/proplists-spec-cleanup/OTP-10663:
Ensure that edocumentation and the xml file are in sync
Clean up some specs
|
|
* ks/kernel/dist_util-minor-fix/OTP-10662:
Do not return wrong terms unnecessarily
|
|
* hb/parsetools/remove_esyntax/OTP-10660:
Remote the file esyntax.yrl
|
|
|
|
|
|
|
|
|
|
|
|
Code written by Siri Hansen.
|
|
Code written by Siri Hansen.
|
|
A few examples in lib/stdlib/doc/src/unicode_usage.xml make use of
Cyrillic characters.
|
|
|
|
Not complete.
Unicode in wild attribute doesn't work.
No support for Unicode regarding Igor stubs.
|
|
|
|
|
|
Expect modifications, additions and corrections.
There is a kludge in file_io_server and
erl_scan:continuation_location() that's not so pleasing.
|
|
* hb/stdlib/spec_improvements/OTP-10658:
[stdlib] Correct and improve specs and types of erl_scan and sys
|
|
Thanks to Kostis Sagonas.
|
|
If one test failed, the next would sometimes also fail since cover was
not stopped.
|
|
* fredrik/ssh/sftp-file-is-dir/OTP-6406:
Removed unused code ssh.erl and changed tests
Added eexist to return proper sftp parameter
Changed erlclient testcases for sftp
sftp ver6 mods, SSH_FX_CANNOT_DELETE added as parameter
Updated doc for sftpd_vsn
Changed testcases to proper sftpd listening
changed option to sftpd_vsn
corrected is_dir call in sftpd
Changes to sftpd test suite
Added a file_is_a_directory to a proper status return
Basic functionality for sftp ver6 and testcase
Conflicts:
lib/ssh/doc/src/ssh_sftpd.xml
|
|
* fredrik/ssh/fix-appup-syntax/OTP-10657:
Fixed syntax error in ssh appup file
|
|
|
|
|
|
OTP-10027
|
|
Updated manager test suite to use only the api. The test cases
that tested the old api (01), are now skipped.
OTP-10027
|
|
OTP-10027
|
|
Removed deprecated functions from the SNMP manager interface
module snmpm. Also updated otp_internal in the stdlib app.
OTP-10027
|
|
* siri/common_test/ct_netconfc-adjust_window/OTP-10646:
[common_test] Adjust window after netconf client receives data
|
|
Before terminating slave nodes, common_test calls cover:flush/1 to
fetch data from the node without actually stopping cover on this
node. If cover is not stopped for the node and a new node with the
same name is started, then cover will be started on the new node. To
avoid this common_test now calls cover:stop/1 after the slave node is
terminated.
|
|
Before terminating slave nodes, test_server calls cover:flush/1 to
fetch data from the node without actually stopping cover on this
node. If cover is not stopped for the node and a new node with the
same name is started, then cover will be started on the new node. To
avoid this test_server now calls cover:stop/1 after the slave node is
terminated.
|
|
|
|
|
|
* pan/process_info_spec_doc/r16/OTP-10584:
Correct doc re process_info(Pid,links)
|
|
|
|
* jd/file-ram-opt-doc:
Move ram option from mode() type into open/2 spec
Basic documentation of the 'ram' mode in the 'file' module
OTP-10651
|
|
The mode() type is used in path_open and copy, two functions that
do _not_ accept the ram option (or is at least not supposed to),
why I moved the option 'ram' from the type down to the spec for
open itself. That also makes the option visible directly under open/2
in the documentation.
|
|
|
|
* pan/seq_trace_match_spec/OTP-10522:
Teach VM not to dump core on faulty seq_trace in ms
|