diff options
author | Björn Gustavsson <[email protected]> | 2018-01-04 13:28:22 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2018-01-08 08:06:43 +0100 |
commit | 1ee21858db7e55b15c2f947ddfa00ae5af5c009d (patch) | |
tree | 4d2607eeeae3015bc2eb3499aca305083ac6f078 /lib/compiler/src/beam_type.erl | |
parent | 31782c3accacafb20bc7efd46004921aea8f9f22 (diff) | |
download | otp-1ee21858db7e55b15c2f947ddfa00ae5af5c009d.tar.gz otp-1ee21858db7e55b15c2f947ddfa00ae5af5c009d.tar.bz2 otp-1ee21858db7e55b15c2f947ddfa00ae5af5c009d.zip |
beam_validator: Strengthen validation of GC instructions
beam_validator did not verify that the Y registers were initialized
before executing the following instructions that could cause a GC:
bs_append/8
bs_init2/6
bs_init_bits/6
gc_bif1/5
gc_bif2/6
gc_bif3/7
test_heap/2
That means that, for example, an incorrect optimization that replaced
an 'allocate_zero' instruction with an 'allocate' instruction when it
was not safe, would not be rejected by beam_validtor, but would
instead cause a crash or other undefined behavior at runtime.
Also fix a minor bug in beam_type exposed by the stronger checking.
When compiling from .S files, beam_type did not handle the
init/1 instruction and could produce unsafe code.
Diffstat (limited to 'lib/compiler/src/beam_type.erl')
-rw-r--r-- | lib/compiler/src/beam_type.erl | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/compiler/src/beam_type.erl b/lib/compiler/src/beam_type.erl index 3d842a6fd3..3446430aaf 100644 --- a/lib/compiler/src/beam_type.erl +++ b/lib/compiler/src/beam_type.erl @@ -367,6 +367,8 @@ flt_need_heap_2({set,_,_,get_list}, H, Fl) -> {[],H,Fl}; flt_need_heap_2({set,_,_,{try_catch,_,_}}, H, Fl) -> {[],H,Fl}; +flt_need_heap_2({set,_,_,init}, H, Fl) -> + {[],H,Fl}; %% All other instructions should cause the insertion of an allocation %% instruction if needed. flt_need_heap_2(_, H, Fl) -> |