aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator
AgeCommit message (Collapse)Author
2010-05-12Merge branch 'bg/opt-receive' into devErlang/OTP
* bg/opt-receive: Test that gen_server:call/2,3 are fast even with a huge message queue erts: Add tests for the receive optimization Update primary bootstrap erts: Implement recv_mark/1 and recv_set/1 for real compiler tests: Cover the error handling code in beam_receive compiler test: Test optimization of receive statements Optimize selective receives in the presence of a large message queue Introduce the new recv_mark/1 and recv_mark/1 instructions Compile tests that communicate with R12 nodes with the r12 option Move p_run/2 to test_lib gen: Inline wait_resp_mon/2 to help the compiler optimize OTP-8623 bg/opt-receive reveive statements that can only read out a newly created reference are now specially optimized so that it will execute in constant time regardless of the number of messages in the receive queue for the process. That optimization will benefit calls to gen_server:call(). (See gen:do_call/4 for an example of a receive statement that will be optimized.)
2010-05-11erts: Add tests for the receive optimizationBjörn Gustavsson
2010-05-11erts: Implement recv_mark/1 and recv_set/1 for realBjörn Gustavsson
The recv_mark/1 instruction will both save the current position in the message queue and a mark (the address of the loop_rec/2 instruction just following the recv_set/1 instruction). The recv_mark/1 instruction will only use the saved position if the mark is correct. The reason for saving and verifying the mark is that the compiler does not need to guarantee that no other receive instruction can be executed in between the recv_mark/1 and recv_set/1 instructions (the mark will be cleared by the remove_message/0 instruction when a message is removed from the message queue). That means that arbitrary function calls in between those instruction can be allowed.
2010-05-11Introduce the new recv_mark/1 and recv_mark/1 instructionsBjörn Gustavsson
Make the recv_mark/1 and recv_mark/1 instructions known to the compiler and run-time system. For the moment, make the loader ignore any occurrences of those instructions in BEAM files. Also update hipe_beam_to_icode to ignore those instructions.
2010-05-11Compile tests that communicate with R12 nodes with the r12 optionBjörn Gustavsson
R12 nodes cannot load code that use the optimized receive that we are about to implement.
2010-05-05OTP-8581 Revert prototype of driver_asyncPatrik Nyblom
2010-05-03allow open_port to set env vars containing a trailing '=' characterSteve Vinoski
The erlang:open_port spawn and spawn_executable directives can include an {env, Env} directive to set up environment variables for the spawned process. A bug in ert/emulator/sys/unix/sys.c prevented applications from using {env, Env} to set an environment variable whose value ended with a '=' (equal sign) character; the code mistook the trailing equal sign as an indication that an environment variable was to be cleared from the environment of the spawned process. For example, passing an {env, Env} of {env, [{"foo", "bar="}]} would result in the code in sys.c seeing a string of the form "foo=bar=" The code would see the final '=' character and assume the directive wanted to clear a variable named "foo=bar" from the environment of the spawned process, rather than seeing it as a directive to set the environment variable "foo" to the value "bar=". Fix this problem and add a new regression test for it to the port test suite.
2010-05-02Merge branch 'bg/remove-stray-ose-support' into devErlang/OTP
* bg/remove-stray-ose-support: configure: Remove stray OSE/Delta support Makefiles: Remove stray OSE/Delta support kernel tests: Remove stray OSE/Delta support system tests: Remove stray OSE/Delta support erl_interface tests: Remove stray OSE/Delta support epmd: Remove stray OSE/Delta support epmd: #ifdef out start_epmd() for other platforms than VxWorks emulator tests: Remove stray OSE/Delta support emulator: Remove stray OSE/Delta support emulator: Eliminate #ifdef for sys_tty_reset() test_server: Remove stray support for OSE/Delta OTP-8585 bg/remove-stray-ose-support
2010-04-30Makefiles: Remove stray OSE/Delta supportBjörn Gustavsson
2010-04-30emulator tests: Remove stray OSE/Delta supportBjörn Gustavsson
2010-04-30emulator: Remove stray OSE/Delta supportBjörn Gustavsson
2010-04-30emulator: Eliminate #ifdef for sys_tty_reset()Björn Gustavsson
In the erts/emulator/beam sources #ifdef SOME_OPERATING_SYSTEM should be avoided. Instead, call a function implemented in sys/OPERATING_SYSTEM/sys.c.
2010-04-28OTP-8591 Race in mseg cashe on non-SMP with async threadsSverker Eriksson
Fix memory management bug causing crash of non-SMP emulator with async threads enabled. The bug did first appear in R13B03.
2010-04-28OTP-8474 NIF improvements after R13B04Sverker Eriksson
New NIF API function enif_make_new_binary
2010-04-20re: Fix non-termination for a certain regular expressionMichael Santos
The following code never terminates: fail() -> Str = "http:/www.flickr.com/slideShow/index.gne?group_id=&user_id=69845378@N0", EMail_regex = "[a-z0-9!#$%&'*+/=?^_`{|}~-]+" ++ "(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*" ++ "@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+" ++ "(?:[a-zA-Z]{2}|com|org|net|gov|mil" ++ "|biz|info|mobi|name|aero|jobs|museum)", io:format("about to run...~n"), Ret = re:run(Str, EMail_regex), io:format("Ret is ~p~n", [Ret]). Fix it by having pcre_exec remember match_call_count between restarts. Reported-by: Gordon Guthrie Acked-by: Patrik Nyblom
2010-04-14MacOS X: Boost default stack sizeBjörn Gustavsson
The default stack size on MacOS X for the SMP emulator is too small to support all uses of pcre. For example, the following expression N = 819, re:compile([lists:duplicate(N, $(), lists:duplicate(N, $))]). will cause a stack overflow. By bisection of different values for the +sss option, I found that 166 is the smallest value that avoids the crash. Round that up to 256 to give a nice, round power of 2 and a resonable safety margin. Use that value as a default stack size on MacOS X only.
2010-04-14Fix check for compile workspace overflowMichael Santos
Patch from: http://vcs.pcre.org/viewvc/code/trunk/pcre_compile.c?r1=504&r2=505&view=patch Test case: N = 819, re:compile([lists:duplicate(N, $(), lists:duplicate(N, $))]). Compiling large regular expressions could overflow the workspace buffer. Modify the test to check for a value smaller than the buffer size.
2010-04-13Merge branch 'bg/fconv' into devErlang/OTP
* bg/fconv: erts: Fix loading of modules with invalid floating point arithmetic
2010-04-08system_info(procs): Fix the value for "OldHeap unused"Satoshi Kinoshita
The value for "OldHeap unused" in the output of erlang:system_info(procs) and in crash dumps, was incorrectly calculated as the size of the entire old heap.
2010-04-07erts: Fix loading of modules with invalid floating point arithmeticBjörn Gustavsson
The following program is supposed to cause an exception at run-time: foo() -> Sum1 = Sum2 = N = 2, pSum - (Sum1*(Sum2/N)). but the loader fails to load because it contains the following instruction: fconv {atom,pSum} {fr,2} Fix the loader so that it can handle fconv instructions where the first operand is a non-numeric literal. Reported-by: Torbjörn Törnkvist
2010-03-30Merge branch 'se/decode_packet' into devErlang/OTP
* se/decode_packet: Fix erlang:decode_packet(httph_bin,..) to not return faulty header strings OTP-8548 se/decode_packet erlang:decode_packet(httph_bin,..) could return corrupt header strings or even crash the VM. This has been fixed. It only happened on 32-bit VM if the header name was unknown and between 16 and 20 characters long. Sockets with simular packet option did not suffer from this bug.
2010-03-29Fix erlang:decode_packet(httph_bin,..) to not return faulty header stringsSverker Eriksson
Unrecognized Http header names was sometimes returned as corrupt sub-binaries pointing to a stack allocated buffer. This only happened on 32-bit VM if the header name was between 16 and 20 characters long. It could in some cases lead to segmentation fault. The solution was to avoid creating sub-binary if the returned string was not part of the original binary.
2010-03-25Merge branch 'bg/compiler-remove-r11-support' into devErlang/OTP
* bg/compiler-remove-r11-support: compiler: Don't support the no_binaries option erts: Don't support the put_string/3 instruction compiler: Don't support the no_constant_pool option compiler: Don't support the r11 option test_server: Don't support communication with R11 nodes binary_SUITE: Don't test bit-level binary roundtrips with R11 nodes erts: Test compatibility of funs with R12 instead of R11 OTP-8531 bg/compiler-remove-r11-support
2010-03-22erts: Don't support the put_string/3 instructionBjörn Gustavsson
Since R14 does not need to load code that can also be loaded in an R11 run-time system, support for the put_string/3 instruction can be removed.
2010-03-22binary_SUITE: Don't test bit-level binary roundtrips with R11 nodesBjörn Gustavsson
2010-03-22erts: Test compatibility of funs with R12 instead of R11Björn Gustavsson
2010-03-22Merge branch 'pan/otp_8332_halfword' into devErlang/OTP
* pan/otp_8332_halfword: Teach testcase in driver_suite the new prototype for driver_async wx: Correct usage of driver callbacks from wx thread Adopt the new (R13B04) Nif functionality to the halfword codebase Support monitoring and demonitoring from driver threads Fix further test-suite problems Correct the VM to work for more test suites Teach {wordsize,internal|external} to system_info/1 Make tracing and distribution work Turn on instruction packing in the loader and virtual machine Add the BeamInstr data type for loaded BEAM code Fix the BEAM dissambler for the half-word emulator Store pointers to heap data in 32-bit words Add a custom mmap wrapper to force heaps into the lower address range Fit all heap data into the 32-bit address range
2010-03-12Teach testcase in driver_suite the new prototype for driver_asyncPatrik Nyblom
The testcase core dunmped. Also made sure the key could actually store long integers in driver_async (which is more of a cosmetic change).
2010-03-10Adopt the new (R13B04) Nif functionality to the halfword codebasePatrik Nyblom
Change erl_int_sizes_config to include HALFWORD_HEAP_EMULATOR, which make it possible for the NIFs to figure out the term size.
2010-03-10Support monitoring and demonitoring from driver threadsPatrik Nyblom
The driver in the wx application does monitoring (and demonitoring) from non-scheduler threads. In the non-half-word emulators, data will be modified without the protection of a lock (which is potentially bad), but the half-word emulator will crash in that situation. While at it, also correct an old bug which make assertions fail in the Kernel test suite.
2010-03-10Fix further test-suite problemsPatrik Nyblom
Fix safe_mul in the loader, which caused failures in the bit syntax test cases. Fix yet another Uint in erl_alloc.h (ERTS_CACHE_LINE_SIZE) causing segmentation fault when we have many schedulers (why only in that situation?). Clean up erl_mseg (remove old code for the Linux 32-bit mmap flag). While at it, also remove compilation warnings.
2010-03-10Correct the VM to work for more test suitesPatrik Nyblom
The following test suites now work: send_term_SUITE trace_nif_SUITE binary_SUITE match_spec_SUITE node_container_SUITE beam_literals_SUITE Also add a testcases for system_info({wordsize,internal|external}).
2010-03-10Teach {wordsize,internal|external} to system_info/1Patrik Nyblom
Some test suites need to differentiate between 32-bit terms and 32-bit pointers. While at it, remove some more warnings in process.c for SMP and debug.
2010-03-10Make tracing and distribution workPatrik Nyblom
Rewrite trace code and external coding. Also slightly correct the interface to the match-spec engine to make tracing work. That will make the test suites runnable.
2010-03-10Turn on instruction packing in the loader and virtual machinePatrik Nyblom
2010-03-10Add the BeamInstr data type for loaded BEAM codePatrik Nyblom
For cleanliness, use BeamInstr instead of the UWord data type to any machine-sized words that are used for BEAM instructions. Only use UWord for untyped words in general.
2010-03-10Fix the BEAM dissambler for the half-word emulatorPatrik Nyblom
2010-03-10Store pointers to heap data in 32-bit wordsPatrik Nyblom
Store Erlang terms in 32-bit entities on the heap, expanding the pointers to 64-bit when needed. This works because all terms are stored on addresses in the 32-bit address range (the 32 most significant bits of pointers to term data are always 0). Introduce a new datatype called UWord (along with its companion SWord), which is an integer having the exact same size as the machine word (a void *), but might be larger than Eterm/Uint. Store code as machine words, as the instructions are pointers to executable code which might reside outside the 32-bit address range. Continuation pointers are stored on the 32-bit stack and hence must point to addresses in the low range, which means that loaded beam code much be placed in the low 32-bit address range (but, as said earlier, the instructions themselves are full words). No Erlang term data can be stored on C stacks (enforced by an earlier commit). This version gives a prompt, but test cases still fail (and dump core). The loader (and emulator loop) has instruction packing disabled. The main issues has been in rewriting loader and actual virtual machine. Subsystems (like distribution) does not work yet.
2010-03-10Add a custom mmap wrapper to force heaps into the lower address rangePatrik Nyblom
The free list is still rudimentary for the mmap wrapper and a better implementation will be needed for production quality.
2010-03-10Fit all heap data into the 32-bit address rangePatrik Nyblom
This is the first step in the implementation of the half-word emulator, a 64-bit emulator where all pointers to heap data will be stored in 32-bit words. Code specific for this emulator variant is conditionally compiled when the HALFWORD_HEAP define has a non-zero value. First force all pointers to heap data to fall into a single 32-bit range, but still store them in 64-bit words. Temporary term data stored on C stack is moved into scheduler specific storage (allocated as heaps) and macros are added to make this happen only in emulators where this is needed. For a vanilla VM the temporary terms are still stored on the C stack.
2010-03-10OTP-8475 status lock needed when looking up ioq from async threadsRickard Green
Driver threads, such as async threads, using <seealso marker="erl_driver#ErlDrvPDL">port data locks</seealso> peeked at the port status field without proper locking when looking up the driver queue.
2010-03-10OTP-8487 unregister/1 on a port can cause the non-smp runtime to crashRickard Green
A call to the BIF unregister(RegName) when a port had the name RegName registered in the runtime system without SMP support caused a runtime system crash. (Thanks to Per Hedeland for the bugfix and test case.)
2010-02-18OTP-8451 Harmless buffer overflow by one byte in asn1 and ram_file_drv.Sverker Eriksson
2010-02-12Merge branch 'ms/pcre-security' into ccase/r13b04_devErlang/OTP
* ms/pcre-security: Fix CVE-2008-2371 (outer level option with alternatives caused crash). OTP-8438 The re module: A regular expression with an option change at the start of a pattern that had top-level alternatives could cause overwriting and/or a crash. (Thanks to Michael Santos.)
2010-02-11Merge branch 'ks/erts' into ccase/r13b04_devErlang/OTP
* ks/erts: hipe_bif0.c: Remove $Id$ erts/preloaded: Add types and specs
2010-02-11hipe_bif0.c: Remove $Id$Kostis Sagonas
2010-02-11OTP-8335 Even more NIF featuresSverker Eriksson
2010-02-11Fix CVE-2008-2371 (outer level option with alternatives caused crash).Michael Santos
The patch is from: http://vcs.pcre.org/viewvc?revision=360&view=revision Test case: re:compile(<<"(?i)[\xc3\xa9\xc3\xbd]|[\xc3\xa9\xc3\xbdA]">>, [unicode]). An option change at the start of a pattern that had top-level alternatives could cause overwriting and/or a crash. This potential security problem was recorded as CVE-2008-2371.
2010-02-10OTP-8420 Fix processes in exiting status that are about to be scheduled,Björn-Egil Dahlberg
to not be allowed to garbage collect.
2010-02-10Merge branch 'egil/lcnt' into ccase/r13b04_devErlang/OTP
* egil/lcnt: Add test suite for lcnt in tools Add lcnt:rt_opt/1 bindings to erts_debug Add runtime option to enable/disable lcnt stats Add auto width on string output Add lcnt documentation Add lock profiling tool OTP-8424 Add lock profiling tool. The Lock profiling tool, lcnt, can make use of the internal lock statistics when the runtime system is built with this feature enabled. This provides a mechanism to examine potential lock bottlenecks within the runtime itself. - Add erts_debug:lock_counters({copy_save, bool()}). This option enables or disables statistics saving for destroyed processes and ets-tables. Enabling this might consume a lot of memory. - Add id-numbering for lock classes which is otherwise undefined.