These are chat archives for synrc/n2o

22nd
Mar 2017
fxmy wang
@fxmy
Mar 22 2017 10:36
So it's a code loading issue between mad_repl.beam bundled in mad script and ./deps/mad/ebin/mad_repl.beam in deps.
I even would suspect when you do a ./mad com repl all beams inside mad app will be from ./deps/mad/ebin/.
./mad rep
Configuration: [{active,[{compile_on_static,true}]},
                {n2o,
                    [{port,8000},
                     {app,switch_watchman},
...............
=INFO REPORT==== 22-Mar-2017::18:36:40 ===
syn_registry_table was successfully created
=INFO REPORT==== 22-Mar-2017::18:36:40 ===
syn_groups_table was successfully created
=INFO REPORT==== 22-Mar-2017::18:36:40 ===
n2o_async:Async Start Attempt {handler,"timer",n2o,system,n2o,[],[]}
=INFO REPORT==== 22-Mar-2017::18:36:40 ===
Copy of syn_registry_table is already added to current node
=INFO REPORT==== 22-Mar-2017::18:36:40 ===
Copy of syn_groups_table is already added to current node==> "active"
......

1> gen_event:which_handlers(error_logger).
[error_logger_tty_h]
2> mad_repl:module_info(md5).
<<84,131,17,44,2,112,2,30,74,13,240,190,16,173,7,19>>
3>
fxmy wang
@fxmy
Mar 22 2017 10:42
./mad com repl
==> "syn"
................
==> "ranch"
==> "/home/fxmy/github/switch_watchman"
OK
Configuration: [{active,[{compile_on_static,true}]},
                ...........
1> ==> "switch_watchman"
==> "/home/fxmy/github/switch_watchman"
==> "syn"
...............

Apps couldn't be loaded: [snmp]
==> "erlydtl"
..........................
==> "ranch"

1> 
1> gen_event:which_handlers(error_logger).
[error_logger]
2> mad_repl:module_info(md5).
<<247,162,176,87,9,101,53,240,182,45,159,247,110,21,177,
  166>>
3>
This explains the call path highjack.
Need dig docs for code loading now...
And also please notice the difference of error_logger handlers.
fxmy wang
@fxmy
Mar 22 2017 10:47
The INFO REPORT not printed in the ./mad com rep case.. Haven't got clue why this would happen thouth.. _(:3JZ)_
fxmy wang
@fxmy
Mar 22 2017 11:05
One other thing that costs me lots of hair last night is that once you trying to trace the call path of mad_repl, the code loading behavior is fucking gone. Like this:
-module(mad_local).
-compile(export_all).

     compile(Params)   ->
       dbg:tracer(port, dbg:trace_port(file, "tracelog")),
       dbg:p(all,c),
       dbg:tpl(mad_repl, '_', '_', [{'_',[],[{return_trace}]}]),
       mad_compile:compile(Params).
     app(Params)       -> mad_static:app(Params).
fxmy wang
@fxmy
Mar 22 2017 11:17
In fact, you don't even need dbg:p(all,c), just start a tracer, tpl module mad_repl before mad_compile:compile(Params) and the issue is GONE... Thought I was hitting a heisenbug last night..
This probably is due to how the Erlang debugger works internally when coming across code loading. Definitely deserves an erlang-question. :laughing: