[erlang-questions] Hipe and memory alignment (Yikes! erts_alloc() returned misaligned address)

Paul Guyot <>
Wed Aug 4 23:50:53 CEST 2010


Le 4 août 2010 à 23:19, Mikael Pettersson a écrit :

> Now, it is possible that the alignment is wrong, esp. if the data
> segment for whatever reason turns out to be tiny.  Please rebuild
> the erlang VM with the following patch and do what you normally do
> to trigger the Yikes! message.  It should tell us a little bit more
> about the allocation parameters.
> 
> FWIW, I've never heard of anyone being able to trigger this warning
> before.

Mikael,

Thank you for your quick reply.
I just invoke erl on FreeBSD 8.0 GENERIC running on amd64 with erlang configured with --enable-native-libs.

Apprently, it's quite common with FreeBSD:
http://www.erlang.org/cgi-bin/ezmlm-cgi/4/41055
http://www.erlang.org/cgi-bin/ezmlm-cgi/4/41237

Your patch reveals that the hipe loader tries to allocate 0 byte, which FreeBSD optimizes by giving only 2 bytes (where MacOS X 10.6 gives 16).

> ./bin/erl
Yikes! erts_alloc() returned 0x80169917e for align 8 nrbytes 0
Yikes! erts_alloc() returned 0x80169917c for align 8 nrbytes 0
Yikes! erts_alloc() returned 0x80169917a for align 8 nrbytes 0
Yikes! erts_alloc() returned 0x801699176 for align 8 nrbytes 0
Yikes! erts_alloc() returned 0x801699174 for align 8 nrbytes 0
Yikes! erts_alloc() returned 0x801699172 for align 8 nrbytes 0
Yikes! erts_alloc() returned 0x80169916e for align 8 nrbytes 0
Yikes! erts_alloc() returned 0x80169916c for align 8 nrbytes 0
Yikes! erts_alloc() returned 0x80169916a for align 8 nrbytes 0
Yikes! erts_alloc() returned 0x801699166 for align 8 nrbytes 0
Yikes! erts_alloc() returned 0x801699164 for align 8 nrbytes 0
Yikes! erts_alloc() returned 0x801699162 for align 8 nrbytes 0
Yikes! erts_alloc() returned 0x80169915e for align 8 nrbytes 0
Yikes! erts_alloc() returned 0x80169915c for align 8 nrbytes 0
Yikes! erts_alloc() returned 0x80169915a for align 8 nrbytes 0
Yikes! erts_alloc() returned 0x801699156 for align 8 nrbytes 0
Yikes! erts_alloc() returned 0x801699154 for align 8 nrbytes 0
Yikes! erts_alloc() returned 0x801699152 for align 8 nrbytes 0
Yikes! erts_alloc() returned 0x80169914e for align 8 nrbytes 0
Yikes! erts_alloc() returned 0x80169914c for align 8 nrbytes 0
Yikes! erts_alloc() returned 0x80169914a for align 8 nrbytes 0
Yikes! erts_alloc() returned 0x801699146 for align 8 nrbytes 0
Yikes! erts_alloc() returned 0x801699144 for align 8 nrbytes 0
Yikes! erts_alloc() returned 0x801699142 for align 8 nrbytes 0
Yikes! erts_alloc() returned 0x80169913e for align 8 nrbytes 0
Yikes! erts_alloc() returned 0x80169913c for align 8 nrbytes 0
Yikes! erts_alloc() returned 0x80169913a for align 8 nrbytes 0
Yikes! erts_alloc() returned 0x801699136 for align 8 nrbytes 0
Yikes! erts_alloc() returned 0x801699134 for align 8 nrbytes 0
Yikes! erts_alloc() returned 0x801699132 for align 8 nrbytes 0
Yikes! erts_alloc() returned 0x80169912e for align 8 nrbytes 0
Yikes! erts_alloc() returned 0x80169912c for align 8 nrbytes 0
Erlang R14A (erts-5.8) [source] [64-bit] [smp:8:8] [rq:8] [async-threads:0] [hipe] [kernel-poll:false]

Yikes! erts_alloc() returned 0x80169912a for align 8 nrbytes 0
Yikes! erts_alloc() returned 0x801699126 for align 8 nrbytes 0
Yikes! erts_alloc() returned 0x801699124 for align 8 nrbytes 0
Yikes! erts_alloc() returned 0x801699122 for align 8 nrbytes 0
Yikes! erts_alloc() returned 0x80169911e for align 8 nrbytes 0
Eshell V5.8  (abort with ^G)
Yikes! erts_alloc() returned 0x80169911c for align 8 nrbytes 0
1> 


Avoiding the allocation when data size is 0 (which means there are only terms in the constants map, I guess), just removes the warning.

Paul

diff --git a/lib/kernel/src/hipe_unified_loader.erl b/lib/kernel/src/hipe_unified_loader.erl
index f289b81..d7747f6 100644
--- a/lib/kernel/src/hipe_unified_loader.erl
+++ b/lib/kernel/src/hipe_unified_loader.erl
@@ -654,7 +654,10 @@ bif_address(Name) when is_atom(Name) ->
 %%
 create_data_segment(DataAlign, DataSize, DataList) ->
   %%io:format("create_data_segment: \nDataAlign: ~p\nDataSize: ~p\nDataList: ~p\n",[DataAlign,DataSize,DataList]),
-  DataAddress = hipe_bifs:alloc_data(DataAlign, DataSize),
+  DataAddress = case DataSize of
+    0 -> 0;
+    _ -> hipe_bifs:alloc_data(DataAlign, DataSize)
+  end,
   enter_data(DataList, [], DataAddress, DataSize).
 
 enter_data(List, ConstMap2, DataAddress, DataSize) ->




More information about the erlang-questions mailing list