aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/internal_doc
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2017-11-10 14:43:13 +0100
committerBjörn Gustavsson <[email protected]>2017-11-13 11:48:59 +0100
commit6c2b0ff5eb6009efdfdb3fa7b4ee794804e01bf0 (patch)
tree5d35af75961b751a626ad0b00d4afe2c15b12a4c /erts/emulator/internal_doc
parent1f8177e950715b3444dadfb1624875afe228195b (diff)
downloadotp-6c2b0ff5eb6009efdfdb3fa7b4ee794804e01bf0.tar.gz
otp-6c2b0ff5eb6009efdfdb3fa7b4ee794804e01bf0.tar.bz2
otp-6c2b0ff5eb6009efdfdb3fa7b4ee794804e01bf0.zip
Refuse to load "literals" that can be confused with registers
The 's' operand overloads the tags for pids and ports to represent X and Y registers, respectively. At load time, refuse to load the module if the "literal" term is not a pid or port, as it would be interpreted as a register. This does not happen with normally compiled code, but it can happen if the compiler (or beam_asm) is abused like in the following example: make_bad() -> Pid = self(), Forms = [{attribute, 0, module, bad_s_operand}, {attribute, 0, export, [{test, 0}]}, {function, 0, test, 0, [{clause, 0, [], [], [{call,0,{atom,0,tuple_size},[{integer, 0, Pid}]}]}]}], {ok, Module, Bin} = compile:forms(Forms, [no_copt,no_postopt,report_errors]), code:load_binary(Module, "bad_s_operand.erl", Bin). With this commit applied, the following message will be printed when make_bad() is run: =ERROR REPORT==== 10-Nov-2017::14:47:59 === Loading of bad_s_operand.erl failed: badfile =ERROR REPORT==== 10-Nov-2017::14:47:59 === beam/beam_load.c(2396): Error loading function bad_s_operand:test/0: op bif1_body: bsd: the term '<0.60.0>' would be confused with a register
Diffstat (limited to 'erts/emulator/internal_doc')
0 files changed, 0 insertions, 0 deletions