Skip to content

Instantly share code, notes, and snippets.

@krestenkrab
Created March 4, 2010 10:20
Show Gist options
  • Save krestenkrab/321610 to your computer and use it in GitHub Desktop.
Save krestenkrab/321610 to your computer and use it in GitHub Desktop.
## Erjang session trying to compile a simple erlang file (see foo.erl below).
##
## The good news is, that the compiler (erlc hosten on erjang) runs, and the
## failure happens not during compilation but when the eshell command c("foo")
## tries to load the resulting beam file. That's a substantial chunk of erlang
## code running there.
##
## The bad news is that the written beam file is pretty bogus. Most likely has
## to do with bug(s) in binary assembly, or iolist() handling somewhere.
##
bash-3.2$ ./erl.sh
Eshell V5.7.3 (abort with ^G)
1> c("foo").
Mar 4, 2010 11:10:54 AM erjang.m.erlang.ErlProc check_process_code
INFO: check_process_code not implemented (PID<:39>, foo)
Mar 4, 2010 11:10:54 AM erjang.m.erlang.ErlProc purge_module
INFO: purge_module not implemented (foo)
[compiling fooMar 4, 2010 11:10:54 AM erjang.m.erlang.ErlBif load_module
SEVERE: cannot load module
=ERROR REPORT==== 4-Mar-2010::11:10:54 ===
Loading of /Users/krab/Documents/humio/erlang/foo.beam failed: {io,
[{erlang,
load_module,
[foo,
<<70,79,82,49,0,0,1,220,66,69,65,77,65,98,115,116,0,0,0,0,0,7,111,112,116,105,111,110,115,106,104,2,100,0,7,118,101,114,115,105,111,110,107,0,5,52,46,54,46,51,104,2,100,0,4,116,105,109,101,104,6,98,0,0,7,218,97,3,97,4,97,10,97,10,97,54,104,2,100,0,6,115,111,117,114,99,101,108,0,0,0,42,97,47,97,85,97,115,97,101,97,114,97,115,97,47,97,107,97,114,97,97,97,98,97,47,97,68,97,111,97,99,97,117,97,109,97,101,97,110,97,116,97,115,97,47,97,104,97,117,97,109,97,105,97,111,97,47,97,101,97,114,97,108,97,97,97,110,97,103,97,47,97,102,97,111,97,111,97,46,97,101,97,114,97,108,106,106,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0>>]},
{erlang,
load_module,
2},
{code_server,
try_load_module,
4},
{code_server,
handle_call,
3},
{code_server,
loop,1},
{erlang,
apply,3}]}
bash-3.2$ krab$ hexdump -C foo.beam
00000000 46 4f 52 31 00 00 01 dc 42 45 41 4d 41 62 73 74 |FOR1....BEAMAbst|
00000010 00 00 00 00 00 07 6f 70 74 69 6f 6e 73 6a 68 02 |......optionsjh.|
00000020 64 00 07 76 65 72 73 69 6f 6e 6b 00 05 34 2e 36 |d..versionk..4.6|
00000030 2e 33 68 02 64 00 04 74 69 6d 65 68 06 62 00 00 |.3h.d..timeh.b..|
00000040 07 da 61 03 61 04 61 0a 61 0a 61 36 68 02 64 00 |..a.a.a.a.a6h.d.|
00000050 06 73 6f 75 72 63 65 6c 00 00 00 2a 61 2f 61 55 |.sourcel...*a/aU|
00000060 61 73 61 65 61 72 61 73 61 2f 61 6b 61 72 61 61 |asaearasa/akaraa|
00000070 61 62 61 2f 61 44 61 6f 61 63 61 75 61 6d 61 65 |aba/aDaoacauamae|
00000080 61 6e 61 74 61 73 61 2f 61 68 61 75 61 6d 61 69 |anatasa/ahauamai|
00000090 61 6f 61 2f 61 65 61 72 61 6c 61 61 61 6e 61 67 |aoa/aearalaaanag|
000000a0 61 2f 61 66 61 6f 61 6f 61 2e 61 65 61 72 61 6c |a/afaoaoa.aearal|
000000b0 6a 6a 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |jj..............|
000000c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
000001e0
-module(foo).
-export([main/0]).
main() -> true.
## same session as above, but with verbose module loading, so you can appreciate how
## many modules have been compiled/loaded before it fails :-)
krab$ ./erl.sh
[compiling erl_prim_loader:844ms][compiling erlang:185ms][compiling init:323ms]
[compiling otp_ring0:8ms][compiling prim_file:211ms][compiling prim_inet:356ms]
[compiling prim_zip:137ms][compiling zlib:73ms][compiling error_handler:23ms]
[compiling heart:63ms][compiling error_logger:60ms]
Mar 4, 2010 11:26:28 AM erjang.EModuleManager$ModuleInfo warn_about_unresolved
INFO: unresolved after load: error_logger:warning_map/0
[compiling gen_event:156ms][compiling gen:77ms][compiling proc_lib:169ms]
[compiling application_controller:335ms][compiling ets:262ms][compiling lists:463ms]
[compiling gen_server:147ms][compiling application:44ms][compiling sys:101ms]
[compiling application_master:68ms][compiling kernel:43ms][compiling supervisor:182ms]
[compiling dict:159ms][compiling rpc:115ms][compiling gb_trees:80ms]
[compiling global:407ms][compiling os:69ms][compiling inet_db:338ms]
[compiling inet_config:92ms][compiling inet_udp:25ms][compiling inet:232ms]
[compiling inet_parse:170ms][compiling filename:110ms][compiling string:94ms]
[compiling erl_distribution:17ms][compiling global_group:205ms]
[compiling net_kernel:288ms][compiling file_server:51ms]
[compiling code:99ms][compiling code_server:272ms][compiling packages:30ms]
[compiling hipe_unified_loader:149ms][compiling gb_sets:136ms][compiling standard_error:38ms]
[compiling supervisor_bridge:37ms][compiling user_sup:19ms][compiling user_drv:158ms]
[compiling user:106ms][compiling shell:323ms][compiling kernel_config:44ms]
[compiling queue:70ms][compiling error_logger_tty_h:47ms][compiling c:151ms]
[compiling file:155ms][compiling erl_eval:249ms][compiling orddict:35ms]
[compiling file_io_server:131ms][compiling beam_lib:257ms][compiling ram_file:82ms]
[compiling erl_lint:1330ms][compiling ordsets:30ms][compiling sets:97ms]
[compiling io:94ms][compiling io_lib:107ms][compiling io_lib_format:141ms]
[compiling unicode:104ms]
Eshell V5.7.3 (abort with ^G)
1> c("foo").
[compiling re:130ms][compiling erl_scan:298ms][compiling proplists:318ms]
[compiling erl_parse:1257ms][compiling erl_internal:58ms]
[compiling shell_default:87ms][compiling compile:359ms][compiling epp:240ms]
[compiling sofs:888ms][compiling sys_pre_expand:170ms]
[compiling erl_expand_records:486ms][compiling erl_bits:38ms]
[compiling v3_core:447ms][compiling cerl:484ms][compiling core_lib:88ms]
[compiling sys_core_fold:491ms][compiling erl_bifs:15ms]
[compiling sys_core_dsetel:61ms][compiling v3_kernel:461ms]
[compiling v3_life:526ms][compiling v3_codegen:539ms][compiling beam_block:127ms]
[compiling beam_jump:87ms][compiling beam_utils:155ms][compiling beam_clean:122ms]
[compiling beam_bool:167ms][compiling beam_type:132ms][compiling beam_dead:103ms]
[compiling beam_peep:33ms][compiling beam_bsm:102ms][compiling beam_trim:84ms]
[compiling beam_flatten:29ms][compiling beam_validator:404ms]
[compiling beam_asm:143ms][compiling beam_dict:56ms][compiling beam_opcodes:42ms]
Mar 4, 2010 11:26:58 AM erjang.m.erlang.ErlProc check_process_code
INFO: check_process_code not implemented (PID<:39>, foo)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment