aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2012-10-10 16:01:16 +0200
committerLukas Larsson <[email protected]>2012-10-10 16:04:45 +0200
commite978576becd64f0effbc40977ad7efb8a2b31489 (patch)
tree1bcb98d19321b0263d260613f82453c611caba06
parent0862c07826b3fd5496a9b3bab2bb0b54a8aa7655 (diff)
downloadotp-e978576becd64f0effbc40977ad7efb8a2b31489.tar.gz
otp-e978576becd64f0effbc40977ad7efb8a2b31489.tar.bz2
otp-e978576becd64f0effbc40977ad7efb8a2b31489.zip
Skip fun corruption when lists is native
This is needed as corruption of the index_uniq byte can cause very strange behaviour when the fun is called by native code.
-rw-r--r--erts/emulator/test/binary_SUITE.erl26
1 files changed, 25 insertions, 1 deletions
diff --git a/erts/emulator/test/binary_SUITE.erl b/erts/emulator/test/binary_SUITE.erl
index 58e0cb4096..babdb3363f 100644
--- a/erts/emulator/test/binary_SUITE.erl
+++ b/erts/emulator/test/binary_SUITE.erl
@@ -626,8 +626,32 @@ safe_binary_to_term2(Config) when is_list(Config) ->
bad_terms(suite) -> [];
bad_terms(Config) when is_list(Config) ->
?line test_terms(fun corrupter/1).
-
+
+corrupter(Term) when is_function(Term);
+ is_function(hd(Term));
+ is_function(element(2,element(2,element(2,Term)))) ->
+ %% Check if lists is native compiled. If it is, we do not try to
+ %% corrupt funs as this can create some very strange behaviour.
+ %% To show the error print `Byte` in the foreach fun in corrupter/2.
+ case erlang:system_info(hipe_architecture) of
+ undefined ->
+ corrupter0(Term);
+ Architecture ->
+ {lists, ListsBinary, _ListsFilename} = code:get_object_code(lists),
+ ChunkName = hipe_unified_loader:chunk_name(Architecture),
+ NativeChunk = beam_lib:chunks(ListsBinary, [ChunkName]),
+ case NativeChunk of
+ {ok,{_,[{_,Bin}]}} when is_binary(Bin) ->
+ S = io_lib:format("Skipping corruption of: ~P", [Term,12]),
+ io:put_chars(S);
+ {error, beam_lib, _} ->
+ corrupter0(Term)
+ end
+ end;
corrupter(Term) ->
+ corrupter0(Term).
+
+corrupter0(Term) ->
?line try
S = io_lib:format("About to corrupt: ~P", [Term,12]),
io:put_chars(S)