[erlang-questions] something is looping, but can't figure out where.

Howard Yeh hayeah@REDACTED
Tue May 27 19:05:17 CEST 2008


oops, i keep on forgetting to reply to the list,

Hi Joe,

That's a pretty cool technique!

I now know that io:format is giving me grief. I originally thought
it's because the compiling environment (I am working on a frontend) I
am trying to print is too large, so its being messaged around (and its
output being redirected to groupleader) would peg my CPU and eat up my
memory.

erlang:display(Env).  is ok, presumably because it outputs directly to
stdout. So I ended up storing most of the information in an ets. But
io:format (and even io:write)  still loop.

Sorry for spamming, here's some diagnostic info, the environment
printed with erlang:display.

group leader:<0.24.0>  %% group:server
ETS: [{memory,39235},
     {owner,<0.45.0>},
     {name,'serl-info'},
     {size,80},
     {node,nonode@REDACTED},
     {named_table,true},
     {type,set},
     {keypos,1},
     {protection,protected}]
process memory: {memory,1457220}
Env:
[{definitions,[{specials,[{cons,{#Fun<erl_eval.12.113037538>}},{tuple,{#Fun<erl_eval.12.113037538>}},{not,{#Fun<erl_eval.12.113037538>}},{'==',{#Fun<erl_eval.12.113037538>}},{'*',{#Fun<erl_eval.12.113037538>}},{'/',{#Fun<erl_eval.12.113037538>}},{'-',{#Fun<erl_eval.12.113037538>}},{'+',{#Fun<erl_eval.12.113037538>}},{toplevel,{#Fun<erl_eval.12.113037538>}},{do,{#Fun<erl_eval.12.113037538>}},{if,{#Fun<erl_eval.12.113037538>}},{call,{#Fun<erl_eval.12.113037538>}},{fn,{#Fun<erl_eval.12.113037538>}},{lsc,{#Fun<erl_eval.12.113037538>}},{case,{#Fun<erl_eval.12.113037538>}},{let,{#Fun<erl_eval.12.113037538>}},{'eval-binding',{#Fun<erl_eval.12.113037538>}},{defspecial,{#Fun<serl.8.91001097>}},{defm,{#Fun<serl.8.91001097>}},{def,{#Fun<serl.8.91001097>}},{'specials-output',{#Fun<serl.8.91001097>}},{'specials-export',{#Fun<serl.8.91001097>}},{'macros-output',{#Fun<serl.8.91001097>}},{'macros-export',{#Fun<serl.8.91001097>}},{'functions-output',{#Fun<serl.8.91001097>}},{'functions-export',{#Fun<serl.8.91001097>}},{'functions-import',{#Fun<serl.8.91001097>}},{module,{#Fun<serl.8.91001097>}},{'__atom',{#Fun<serl.8.91001097>}},{'__string',{#Fun<serl.8.91001097>}},{'__float',{#Fun<serl.8.91001097>}},{'__integer',{#Fun<serl.8.91001097>}},{'__brace',{#Fun<serl.8.91001097>}},{'__block',{#Fun<serl.8.91001097>}},{'__eof',{#Fun<serl.8.91001097>}},{'__bof',{#Fun<serl.8.91001097>}}]},{macros,[{ls,{#Fun<erl_eval.6.13229925>}},{begin,{#Fun<erl_eval.6.13229925>}},{'>>',{#Fun<erl_eval.6.13229925>}},{'let*',{#Fun<erl_eval.6.13229925>}},{export,{#Fun<serl.7.37520875>}},{import,{#Fun<serl.7.37520875>}},{'export-from',{#Fun<serl.7.37520875>}},{'import-from',{#Fun<serl.7.37520875>}},{'with-genvar',{#Fun<serl.7.37520875>}}]},{functions,[{'list-of',{#Fun<erl_eval.12.113037538>}},{'una-op',{#Fun<erl_eval.12.113037538>}},{'bin-op',{#Fun<erl_eval.12.113037538>}},{'nest-bin-op',{#Fun<erl_eval.12.113037538>}},{'if-clauses',{#Fun<erl_eval.12.113037538>}},{'remote-call',{#Fun<erl_eval.12.113037538>}},{'local-call',{#Fun<erl_eval.12.113037538>}},{'fn-value',{#Fun<erl_eval.12.113037538>}},{'lsc-bindings',{#Fun<erl_eval.12.113037538>}},{'let-bindings',{#Fun<erl_eval.12.113037538>}},{'macro-arg-end',{#Fun<serl.6.115586673>}},{'macro-aux-blocks',{#Fun<serl.6.115586673>}},{'macro-arg-blocks-2',{#Fun<serl.6.115586673>}},{'macro-arg-blocks',{#Fun<serl.6.115586673>}},{'macro-parse-args',{#Fun<serl.6.115586673>}},{'output-meta-fun',{#Fun<serl.6.115586673>}},{'output-fun',{#Fun<serl.6.115586673>}},{'get-defs',{#Fun<serl.6.115586673>}},{'def-info',{#Fun<serl.6.115586673>}},{'new-def',{#Fun<serl.6.115586673>}},{'get-exports',{#Fun<serl.6.115586673>}},{'export-defs',{#Fun<serl.6.115586673>}},{'output-forms',{#Fun<serl.6.115586673>}},{cleanup,{#Fun<serl.6.115586673>}},{'guard-seq',{#Fun<serl.6.115586673>}},{'guarded-clause',{#Fun<serl.6.115586673>}},{clause,{#Fun<serl.6.115586673>}},{'atom-cat',{#Fun<serl.6.115586673>}},{'split-tail',{#Fun<serl.6.115586673>}},{'upto-block',{#Fun<serl.6.115586673>}},{erlpp,{#Fun<serl.6.115586673>}},{'ast-data',{#Fun<serl.6.115586673>}},{'ast-mod',{#Fun<serl.6.115586673>}},{'ast-line',{#Fun<serl.6.115586673>}},{'ast-tag',{#Fun<serl.6.115586673>}}]}]},{exports,[{macros,[{'__atom',71,serl,'export-from'},{'__atom',71,serl,'import-from'},{'__atom',72,serl,export},{'__atom',72,serl,import},{'__atom',73,serl,'let*'},{'__atom',73,serl,'>>'},{'__atom',74,serl,begin},{'__atom',75,serl,ls}]},{specials,[{'__atom',42,serl,'__eof'},{'__atom',42,serl,'__bof'},{'__atom',42,serl,'__block'},{'__atom',42,serl,'__brace'},{'__atom',42,serl,'__integer'},{'__atom',42,serl,'__float'},{'__atom',42,serl,'__string'},{'__atom',42,serl,'__atom'},{'__atom',54,serl,module},{'__atom',55,serl,def},{'__atom',55,serl,defm},{'__atom',55,serl,defspecial},{'__atom',56,serl,'functions-import'},{'__atom',56,serl,'functions-export'},{'__atom',56,serl,'functions-output'},{'__atom',58,serl,'macros-export'},{'__atom',58,serl,'macros-output'},{'__atom',60,serl,'specials-export'},{'__atom',60,serl,'specials-output'},{'__atom',61,serl,'eval-binding'},{'__atom',62,serl,let},{'__atom',62,serl,lsc},{'__atom',63,serl,fn},{'__atom',63,serl,call},{'__atom',64,serl,case},{'__atom',64,serl,if},{'__atom',65,serl,do},{'__atom',65,serl,toplevel},{'__atom',66,serl,tuple},{'__atom',66,serl,cons},{'__atom',67,serl,'+'},{'__atom',67,serl,'-'},{'__atom',67,serl,'*'},{'__atom',67,serl,'/'},{'__atom',67,serl,'=='},{'__atom',68,serl,not}]},{functions,[{'__atom',44,serl,'ast-tag'},{'__atom',44,serl,'ast-line'},{'__atom',44,serl,'ast-mod'},{'__atom',44,serl,'ast-data'},{'__atom',45,serl,'upto-block'},{'__atom',46,serl,'atom-cat'},{'__atom',47,serl,erlpp},{'__atom',48,serl,'output-forms'}]}]},{lexical,[]},{imports,[{erlang,[{functions,[{length,{{erlang,length}}},{self,{{erlang,self}}}]}]},{lists,[{functions,[{foldl,{{lists,foldl}}},{foldr,{{lists,foldr}}},{foreach,{{lists,foreach}}},{map,{{lists,map}}},{member,{{lists,member}}},{reverse,{{lists,reverse}}}]}]},{scompile,[{functions,[{curmod,{{scompile,curmod}}},{error,{{scompile,error}}},{gensym,{{scompile,gensym}}},{genvar,{{scompile,genvar}}},{is_curmod,{{scompile,is_curmod}}},{lineno,{{scompile,lineno}}},{map_env0,{{scompile,map_env0}}},{transform,{{scompile,transform}}},{transform_each,{{scompile,transform_each}}}]}]},{serl,[{functions,[{'ast-tag',{{serl,'ast-tag'},[{doc,[]}]}},{'ast-line',{{serl,'ast-line'},[{doc,[]}]}},{'ast-mod',{{serl,'ast-mod'},[{doc,[]}]}},{'ast-data',{{serl,'ast-data'},[{doc,[]}]}},{'upto-block',{{serl,'upto-block'},[{doc,[]}]}},{'atom-cat',{{serl,'atom-cat'},[{doc,[]}]}},{erlpp,{{serl,erlpp},[{doc,[]}]}},{'output-forms',{{serl,'output-forms'},[{doc,[]}]}}]},{macros,[{'export-from',{{serl,'$mac-export-from'},[{doc,[]}]}},{'import-from',{{serl,'$mac-import-from'},[{doc,[]}]}},{export,{{serl,'$mac-export'},[{doc,[]}]}},{import,{{serl,'$mac-import'},[{doc,[]}]}},{'let*',{{serl,'$mac-let*'},[{doc,[]}]}},{'>>',{{serl,'$mac->>'},[{doc,[]}]}},{begin,{{serl,'$mac-begin'},[{doc,[]}]}},{ls,{{serl,'$mac-ls'},[{doc,[]}]}}]},{specials,[{'__eof',{{serl,'$special-__eof'},[{doc,[]}]}},{'__bof',{{serl,'$special-__bof'},[{doc,[]}]}},{'__block',{{serl,'$special-__block'},[{doc,[]}]}},{'__brace',{{serl,'$special-__brace'},[{doc,[]}]}},{'__integer',{{serl,'$special-__integer'},[{doc,[]}]}},{'__float',{{serl,'$special-__float'},[{doc,[]}]}},{'__string',{{serl,'$special-__string'},[{doc,[]}]}},{'__atom',{{serl,'$special-__atom'},[{doc,[]}]}},{module,{{serl,'$special-module'},[{doc,[]}]}},{def,{{serl,'$special-def'},[{doc,[]}]}},{defm,{{serl,'$special-defm'},[{doc,[]}]}},{defspecial,{{serl,'$special-defspecial'},[{doc,[]}]}},{'functions-import',{{serl,'$special-functions-import'},[{doc,[]}]}},{'functions-export',{{serl,'$special-functions-export'},[{doc,[]}]}},{'functions-output',{{serl,'$special-functions-output'},[{doc,[]}]}},{'macros-export',{{serl,'$special-macros-export'},[{doc,[]}]}},{'macros-output',{{serl,'$special-macros-output'},[{doc,[]}]}},{'specials-export',{{serl,'$special-specials-export'},[{doc,[]}]}},{'specials-output',{{serl,'$special-specials-output'},[{doc,[]}]}},{'eval-binding',{{serl,'$special-eval-binding'},[{doc,[]}]}},{let,{{serl,'$special-let'},[{doc,[]}]}},{lsc,{{serl,'$special-lsc'},[{doc,[]}]}},{fn,{{serl,'$special-fn'},[{doc,[]}]}},{call,{{serl,'$special-call'},[{doc,[]}]}},{case,{{serl,'$special-case'},[{doc,[]}]}},{if,{{serl,'$special-if'},[{doc,[]}]}},{do,{{serl,'$special-do'},[{doc,[]}]}},{toplevel,{{serl,'$special-toplevel'},[{doc,[]}]}},{tuple,{{serl,'$special-tuple'},[{doc,[]}]}},{cons,{{serl,'$special-cons'},[{doc,[]}]}},{'+',{{serl,'$special-+'},[{doc,[]}]}},{'-',{{serl,'$special--'},[{doc,[]}]}},{'*',{{serl,'$special-*'},[{doc,[]}]}},{'/',{{serl,'$special-/'},[{doc,[]}]}},{'==',{{serl,'$special-=='},[{doc,[]}]}},{not,{{serl,'$special-not'},[{doc,[]}]}}]}]},{verl,[{specials,[{'__bof',{{verl,'__sp_bof'}}},{'__eof',{{verl,'__sp_eof'}}},{'__float',{{verl,'__sp_float'}}},{'__integer',{{verl,'__sp_integer'}}},{'__string',{{verl,'__sp_string'}}},{'__atom',{{verl,'__sp_atom'}}},{'__var',{{verl,'__sp_var'}}},{'__block',{{verl,'__sp_block'}}},{'__brace',{{verl,'__sp_brace'}}},{'__call',{{verl,'__sp_call'}}},{'__quote',{{verl,'__sp_quote'}}},{'__bquote',{{verl,'__sp_bquote'}}},{defm,{{verl,'__sp_defm'}}},{'eval-binding',{{verl,'__sp_eval-binding'}}},{let,{{verl,'__sp_let'}}},{module,{{verl,'__sp_module'}}},{export,{{verl,'__sp_export'}}},{import,{{verl,'__sp_import'}}},{record,{{verl,'__sp_record'}}},{def,{{verl,'__sp_def'}}},{tuple,{{verl,'__sp_tuple'}}},{cons,{{verl,'__sp_cons'}}},{nil,{{verl,'__sp_nil'}}},{op,{{verl,'__sp_op'}}},{'+',{{verl,'__sp_+'}}},{'-',{{verl,'__sp_-'}}},{'*',{{verl,'__sp_*'}}},{'/',{{verl,'__sp_/'}}},{rem,{{verl,'__sp_rem'}}},{'++',{{verl,'__sp_++'}}},{'==',{{verl,'__sp_=='}}},{'<',{{verl,'__sp_<'}}},{'>',{{verl,'__sp_>'}}},{'>=',{{verl,'__sp_>='}}},{'=<',{{verl,'__sp_=<'}}},{and,{{verl,'__sp_and'}}},{or,{{verl,'__sp_or'}}},{andalso,{{verl,'__sp_andalso'}}},{orelse,{{verl,'__sp_orelse'}}},{not,{{verl,'__sp_not'}}},{catch,{{verl,'__sp_catch'}}},{if,{{verl,'__sp_if'}}},{case,{{verl,'__sp_case'}}},{try,{{verl,'__sp_try'}}},{fn,{{verl,'__sp_fn'}}},{do,{{verl,'__sp_begin'}}},{begin,{{verl,'__sp_begin'}}}]},{macros,[{ls,{{verl,'__mac_ls'}}},{'>>',{{verl,'__mac_>>'}}},{float,{{verl,'__mac_float'}}},{integer,{{verl,'__mac_integer'}}},{string,{{verl,'__mac_string'}}},{atom,{{verl,'__mac_atom'}}},{var,{{verl,'__mac_var'}}},{block,{{verl,'__mac_block'}}},{paren,{{verl,'__mac_paren'}}},{brace,{{verl,'__mac_brace'}}},{floats,{{verl,'__mac_floats'}}},{integers,{{verl,'__mac_integers'}}},{strings,{{verl,'__mac_strings'}}},{atoms,{{verl,'__mac_atoms'}}},{vars,{{verl,'__mac_vars'}}},{blocks,{{verl,'__mac_blocks'}}},{parens,{{verl,'__mac_parens'}}},{braces,{{verl,'__mac_braces'}}}]},{rmacros,[{a,{{verl,'__rm_a'}}},{c,{{verl,'__rm_c'}}},{s,{{verl,'__rm_s'}}}]},{functions,[{cat,{{lists,append}}},{fmt,{{io,format}}}]}]}]}]


can somebody briefly explain how io works? And how it interacts with
the shell. I was reading the source, but it's hard to make sense of
w/o some guidance. I just need a rough sense of who's talking to whom
about what.

howard
On 5/27/08, Joe Armstrong <erlang@REDACTED> wrote:
> You can mess around with the BIFs processes() and process_info(Pid, Tag)
>
>  These BIFS are described in the man page for Erlang (erl -man erl) (or
>  pre-installed man pages for windows)   (or
>  http://www.erlang.org/doc/man/erlang.html))
>
>  processes() returns a list of all Pids in the system.
>
>  process_info(Pid, Tag) returns process information for the process
>  Pid. Tag says what kind of information
>  you want. process_info(Pid) returns even more info per process
>
>  A command like
>
>  > [ process_info(Pid) || Pid <- processes()]
>  ...
>
>  Will help you track down which process has run  wild.
>
>  Exercise: using processes/0 and process_info/1 (or /2) write a
>  function find_looping_process() that
>  locates the bad process. Hint take two samples with 5 second intervals
>  and compare ...
>
>  /Joe Armstrong
>
>
>
>
>
>  On Sun, May 25, 2008 at 11:23 PM, Howard Yeh <hayeah@REDACTED> wrote:
>  > Hi,
>  >
>  > Earlier I was having problem with not getting the shell prompt back
>  > after a computation (with something looping & consuming memory).
>  > Putting the computation in a process seemed to have solved the
>  > problem.
>  >
>  > Now I am getting looping behaviour again. I am pretty sure my
>  > computation is not looping, since it raises an error (previously I
>  > could see the returned result). This time I have a timeout to kill the
>  > linked computation process after 10 seconds.
>  >
>  > After looping for 10 seconds, the computation process is killed, and i
>  > get the shell prompt back. But something keeps looping (pegs CPU, but
>  > consumes no memory).
>  >
>  > Does c:i() list all the processes? Looking at the reduction counts,
>  > nothing is increasing except the shell related processes. But those
>  > processes are only reducing my sending the i() command.
>  >
>  > I am really confused.
>  >
>  > Howard
>
> > _______________________________________________
>  > erlang-questions mailing list
>  > erlang-questions@REDACTED
>  > http://www.erlang.org/mailman/listinfo/erlang-questions
>  >
>


-- 
hayeah.wordpress.com
   --metacircular thinking



More information about the erlang-questions mailing list