rebar3 icon indicating copy to clipboard operation
rebar3 copied to clipboard

cover fails on Elixir compiled modules

Open tsloughter opened this issue 3 years ago • 4 comments

Not sure we can do anything about this, so may just label 'won't fix' and close, but if there are Elixir compiled beam files in the ebin dir -- in this case I ran mix test followed by rebar3 ct -- there is a crash in cover because of undefined elixir_erl:debug_info and rebar3 blows up:

Error: {case_clause,
        {'EXIT',
         {undef,
          [{elixir_erl,debug_info,
            [erlang_v1,'Elixir.OpenTelemetry',
             {elixir_v1,
              #{attributes => [],compile_opts => [],
                definitions =>
                 [{{timestamp_to_nano,1},
                   def,
                   [{line,158},{context,'Elixir.Kernel'}],
                   [{[{line,158},{context,'Elixir.Kernel'}],
                     [{timestamp,[{version,0},{line,158}],nil}],
                     [],
                     {{'.',[{line,158}],[opentelemetry,timestamp_to_nano]},
                      [{line,158}],
                      [{timestamp,[{version,0},{line,158}],nil}]}}]},
                  {{timestamp,0},
                   def,
                   [{line,151},{context,'Elixir.Kernel'}],
                   [{[{line,151},{context,'Elixir.Kernel'}],
                     [],[],
                     {{'.',[{line,151}],[opentelemetry,timestamp]},
                      [{line,151}],
                      []}}]},
                  {{status,2},
                   def,
                   [{line,219},{context,'Elixir.Kernel'}],
                   [{[{line,219},{context,'Elixir.Kernel'}],
                     [{code,[{version,0},{line,219}],nil},
                      {message,[{version,1},{line,219}],nil}],
                     [],
                     {{'.',[{line,219}],[opentelemetry,status]},
                      [{line,219}],
                      [{code,[{version,0},{line,219}],nil},
                       {message,[{version,1},{line,219}],nil}]}}]},
                  {{set_default_tracer,1},
                   def,
                   [{line,131},{context,'Elixir.Kernel'}],
                   [{[{line,131},{context,'Elixir.Kernel'}],
                     [{t,[{version,0},{line,131}],nil}],
                     [],
                     {{'.',[{line,131}],[opentelemetry,set_default_tracer]},
                      [{line,131}],
                      [{t,[{version,0},{line,131}],nil}]}}]},
                  {{register_tracer,2},
                   def,
                   [{line,130},{context,'Elixir.Kernel'}],
                   [{[{line,130},{context,'Elixir.Kernel'}],
                     [{name,[{version,0},{line,130}],nil},
                      {vsn,[{version,1},{line,130}],nil}],
                     [],
                     {{'.',[{line,130}],[opentelemetry,register_tracer]},
                      [{line,130}],
                      [{name,[{version,0},{line,130}],nil},
                       {vsn,[{version,1},{line,130}],nil}]}}]},
                  {{register_application_tracer,1},
                   def,
                   [{line,127},{context,'Elixir.Kernel'}],
                   [{[{line,127},{context,'Elixir.Kernel'}],
                     [{otp_app,[{version,0},{line,127}],nil}],
                     [],
                     {{'.',
                       [{line,127}],
                       [opentelemetry,register_application_tracer]},
                      [{line,127}],
                      [{otp_app,[{version,0},{line,127}],nil}]}}]},
                  {{register_application_meter,1},
                   def,
                   [{line,134},{context,'Elixir.Kernel'}],
                   [{[{line,134},{context,'Elixir.Kernel'}],
                     [{name,[{version,0},{line,134}],nil}],
                     [],
                     {{'.',
                       [{line,134}],
                       [opentelemetry,register_application_meter]},
                      [{line,134}],
                      [{name,[{version,0},{line,134}],nil}]}}]},
                  {{links,1},
                   def,
                   [{line,195},{context,'Elixir.Kernel'}],
                   [{[{line,195},{context,'Elixir.Kernel'}],
                     [{link_list,[{version,0},{line,195}],nil}],
                     [],
                     {{'.',[{line,195}],[opentelemetry,links]},
                      [{line,195}],
                      [{link_list,[{version,0},{line,195}],nil}]}}]},
                  {{link,4},
                   def,
                   [{line,173},{context,'Elixir.Kernel'}],
                   [{[{line,173},{context,'Elixir.Kernel'}],
                     [{trace_id,[{version,0},{line,173}],nil},
                      {span_id,[{version,1},{line,173}],nil},
                      {attributes,[{version,2},{line,173}],nil},
                      {tracestate,[{version,3},{line,173}],nil}],
                     [],
                     {{'.',[{line,173}],[opentelemetry,link]},
                      [{line,173}],
                      [{trace_id,[{version,0},{line,173}],nil},
                       {span_id,[{version,1},{line,173}],nil},
                       {attributes,[{version,2},{line,173}],nil},
                       {tracestate,[{version,3},{line,173}],nil}]}}]},
                  {{link,2},
                   def,
                   [{line,185},{context,'Elixir.Kernel'}],
                   [{[{line,185},{context,'Elixir.Kernel'}],
                     [{span_ctx,[{version,0},{line,185}],nil},
                      {attributes,[{version,1},{line,185}],nil}],
                     [],
                     {{'.',[{line,185}],[opentelemetry,link]},
                      [{line,185}],
                      [{span_ctx,[{version,0},{line,185}],nil},
                       {attributes,[{version,1},{line,185}],nil}]}}]},
                  {{link,1},
                   def,
                   [{line,179},{context,'Elixir.Kernel'}],
                   [{[{line,179},{context,'Elixir.Kernel'}],
                     [{span_ctx,[{version,0},{line,179}],nil}],
                     [],
                     {{'.',[{line,179}],[opentelemetry,link]},
                      [{line,179}],
                      [{span_ctx,[{version,0},{line,179}],nil}]}}]},
                  {{get_tracer,1},
                   def,
                   [{line,129},{context,'Elixir.Kernel'}],
                   [{[{line,129},{context,'Elixir.Kernel'}],
                     [{name,[{version,0},{line,129}],nil}],
                     [],
                     {{'.',[{line,129}],[opentelemetry,get_tracer]},
                      [{line,129}],
                      [{name,[{version,0},{line,129}],nil}]}}]},
                  {{events,1},
                   def,
                   [{line,213},{context,'Elixir.Kernel'}],
                   [{[{line,213},{context,'Elixir.Kernel'}],
                     [{event_list,[{version,0},{line,213}],nil}],
                     [],
                     {{'.',[{line,213}],[opentelemetry,events]},
                      [{line,213}],
                      [{event_list,[{version,0},{line,213}],nil}]}}]},
                  {{event,3},
                   def,
                   [{line,207},{context,'Elixir.Kernel'}],
                   [{[{line,207},{context,'Elixir.Kernel'}],
                     [{timestamp,[{version,0},{line,207}],nil},
                      {name,[{version,1},{line,207}],nil},
                      {attributes,[{version,2},{line,207}],nil}],
                     [],
                     {{'.',[{line,207}],[opentelemetry,event]},
                      [{line,207}],
                      [{timestamp,[{version,0},{line,207}],nil},
                       {name,[{version,1},{line,207}],nil},
                       {attributes,[{version,2},{line,207}],nil}]}}]},
                  {{event,2},
                   def,
                   [{line,201},{context,'Elixir.Kernel'}],
                   [{[{line,201},{context,'Elixir.Kernel'}],
                     [{name,[{version,0},{line,201}],nil},
                      {attributes,[{version,1},{line,201}],nil}],
                     [],
                     {{'.',[{line,201}],[opentelemetry,event]},
                      [{line,201}],
                      [{name,[{version,0},{line,201}],nil},
                       {attributes,[{version,1},{line,201}],nil}]}}]},
                  {{convert_timestamp,2},
                   def,
                   [{line,165},{context,'Elixir.Kernel'}],
                   [{[{line,165},{context,'Elixir.Kernel'}],
                     [{timestamp,[{version,0},{line,165}],nil},
                      {unit,[{version,1},{line,165}],nil}],
                     [],
                     {{'.',[{line,165}],[opentelemetry,convert_timestamp]},
                      [{line,165}],
                      [{timestamp,[{version,0},{line,165}],nil},
                       {unit,[{version,1},{line,165}],nil}]}}]}],
                deprecated => [],
                file =>
                 <<"/home/tristan/Devel/opentelemetry-erlang/apps/opentelemetry_api/lib/open_telemetry.ex">>,
                is_behaviour => false,line => 1,
                module => 'Elixir.OpenTelemetry',
                relative_file => <<"lib/open_telemetry.ex">>,struct => nil,
                unreachable => []},
              [{attribute,157,spec,
                {{timestamp_to_nano,1},
                 [{type,157,'fun',
                   [{type,157,product,[{type,157,integer,[]}]},
                    {type,157,integer,[]}]}]}},
               {attribute,150,spec,
                {{timestamp,0},
                 [{type,150,'fun',
                   [{type,150,product,[]},{type,150,integer,[]}]}]}},
               {attribute,218,spec,
                {{status,2},
                 [{type,218,'fun',
                   [{type,218,product,
                     [{type,218,atom,[]},
                      {remote_type,218,
                       [{atom,0,'Elixir.String'},{atom,0,t},[]]}]},
                    {user_type,218,status,[]}]}]}},
               {attribute,126,spec,
                {{register_application_tracer,1},
                 [{type,126,'fun',
                   [{type,126,product,[{type,126,atom,[]}]},
                    {type,126,boolean,[]}]}]}},
               {attribute,133,spec,
                {{register_application_meter,1},
                 [{type,133,'fun',
                   [{type,133,product,[{type,133,atom,[]}]},
                    {type,133,boolean,[]}]}]}},
               {attribute,190,spec,
                {{links,1},
                 [{type,194,'fun',
                   [{type,194,product,
                     [{type,0,list,
                       [{type,192,union,
                         [{type,191,tuple,
                           [{type,191,integer,[]},
                            {type,191,integer,[]},
                            {user_type,191,attributes,[]},
                            {user_type,191,tracestate,[]}]},
                          {user_type,192,span_ctx,[]},
                          {type,0,tuple,
                           [{user_type,193,span_ctx,[]},
                            {user_type,193,attributes,[]}]}]}]}]},
                    {type,0,list,[{user_type,194,link,[]}]}]}]}},
               {attribute,172,spec,
                {{link,4},
                 [{type,172,'fun',
                   [{type,172,product,
                     [{user_type,172,trace_id,[]},
                      {user_type,172,span_id,[]},
                      {user_type,172,attributes,[]},
                      {user_type,172,tracestate,[]}]},
                    {user_type,172,link,[]}]}]}},
               {attribute,184,spec,
                {{link,2},
                 [{type,184,'fun',
                   [{type,184,product,
                     [{type,184,union,
                       [{user_type,184,span_ctx,[]},{atom,0,undefined}]},
                      {user_type,184,attributes,[]}]},
                    {user_type,184,link,[]}]}]}},
               {attribute,178,spec,
                {{link,1},
                 [{type,178,'fun',
                   [{type,178,product,
                     [{type,178,union,
                       [{user_type,178,span_ctx,[]},{atom,0,undefined}]}]},
                    {user_type,178,link,[]}]}]}},
               {attribute,212,spec,
                {{events,1},
                 [{type,212,'fun',
                   [{type,212,product,[{type,212,list,[]}]},
                    {type,0,list,[{user_type,212,event,[]}]}]}]}},
               {attribute,206,spec,
                {{event,3},
                 [{type,206,'fun',
                   [{type,206,product,
                     [{type,206,integer,[]},
                      {user_type,206,event_name,[]},
                      {user_type,206,attributes,[]}]},
                    {user_type,206,event,[]}]}]}},
               {attribute,200,spec,
                {{event,2},
                 [{type,200,'fun',
                   [{type,200,product,
                     [{user_type,200,event_name,[]},
                      {user_type,200,attributes,[]}]},
                    {user_type,200,event,[]}]}]}},
               {attribute,164,spec,
                {{convert_timestamp,2},
                 [{type,164,'fun',
                   [{type,164,product,
                     [{type,164,integer,[]},
                      {remote_type,164,
                       [{atom,0,erlang},{atom,0,time_unit},[]]}]},
                    {type,164,integer,[]}]}]}},
               {attribute,116,export_type,[{status,0}]},
               {attribute,116,type,
                {status,
                 {remote_type,116,[{atom,0,opentelemetry},{atom,0,status},[]]},
                 []}},
               {attribute,110,export_type,[{event_name,0}]},
               {attribute,110,type,
                {event_name,
                 {remote_type,110,
                  [{atom,0,opentelemetry},{atom,0,event_name},[]]},
                 []}},
               {attribute,109,export_type,[{event,0}]},
               {attribute,109,type,
                {event,
                 {remote_type,109,[{atom,0,opentelemetry},{atom,0,event},[]]},
                 []}},
               {attribute,103,export_type,[{links,0}]},
               {attribute,103,type,
                {links,
                 {remote_type,103,[{atom,0,opentelemetry},{atom,0,links},[]]},
                 []}},
               {attribute,102,export_type,[{link,0}]},
               {attribute,102,type,
                {link,
                 {remote_type,102,[{atom,0,opentelemetry},{atom,0,link},[]]},
                 []}},
               {attribute,94,export_type,[{tracestate,0}]},
               {attribute,94,type,
                {tracestate,
                 {type,0,list,
                  [{type,0,tuple,
                    [{remote_type,94,[{atom,0,'Elixir.String'},{atom,0,t},[]]},
                     {remote_type,94,
                      [{atom,0,'Elixir.String'},{atom,0,t},[]]}]}]},
                 []}},
               {attribute,83,export_type,[{attributes,0}]},
               {attribute,83,type,
                {attributes,
                 {remote_type,83,
                  [{atom,0,opentelemetry},{atom,0,attributes},[]]},
                 []}},
               {attribute,69,export_type,[{attribute_value,0}]},
               {attribute,69,type,
                {attribute_value,
                 {remote_type,69,
                  [{atom,0,opentelemetry},{atom,0,attribute_value},[]]},
                 []}},
               {attribute,68,export_type,[{attribute_key,0}]},
               {attribute,68,type,
                {attribute_key,
                 {remote_type,68,
                  [{atom,0,opentelemetry},{atom,0,attribute_key},[]]},
                 []}},
               {attribute,66,export_type,[{span_id,0}]},
               {attribute,66,type,{span_id,{type,66,non_neg_integer,[]},[]}},
               {attribute,59,export_type,[{trace_id,0}]},
               {attribute,59,type,{trace_id,{type,59,non_neg_integer,[]},[]}},
               {attribute,52,export_type,[{span_kind,0}]},
               {attribute,52,type,
                {span_kind,
                 {remote_type,52,
                  [{atom,0,opentelemetry},{atom,0,span_kind},[]]},
                 []}},
               {attribute,50,export_type,[{span,0}]},
               {attribute,50,type,
                {span,
                 {remote_type,50,[{atom,0,opentelemetry},{atom,0,span},[]]},
                 []}},
               {attribute,39,export_type,[{tracer_ctx,0}]},
               {attribute,39,type,
                {tracer_ctx,
                 {remote_type,39,
                  [{atom,0,otel_tracer},{atom,0,tracer_ctx},[]]},
                 []}},
               {attribute,33,export_type,[{span_ctx,0}]},
               {attribute,33,type,
                {span_ctx,
                 {remote_type,33,
                  [{atom,0,opentelemetry},{atom,0,span_ctx},[]]},
                 []}}]},
             []],
            []},
           {beam_lib,chunks_to_data,7,[{file,"beam_lib.erl"},{line,685}]},
           {beam_lib,read_chunk_data,3,[{file,"beam_lib.erl"},{line,554}]},
           {beam_lib,read_chunk_data,2,[{file,"beam_lib.erl"},{line,542}]},
           {cover,get_abstract_code,2,[{file,"cover.erl"},{line,1578}]},
           {cover,do_compile_beam1,4,[{file,"cover.erl"},{line,1557}]},
           {cover,do_compile_beam,3,[{file,"cover.erl"},{line,1497}]},
           {lists,map,2,[{file,"lists.erl"},{line,1243}]}]}}}
[]

tsloughter avatar Oct 24 '20 23:10 tsloughter

@tsloughter Can't we just check the chunk data to find out whether the beam file has been compiled by Erlang, Elixir or others and filter those out?

pablocostass avatar Oct 25 '20 09:10 pablocostass

Technically, sure, but is it worth it is the question. And since this is currently failing in cover it isn't a place that we are already touching the modules and could just handle the failure.

In my opinion the best solution is (assuming this works, it might not) simply catching the cover failure, printing a warning about cover not being available, and continuing on.

tsloughter avatar Oct 25 '20 13:10 tsloughter

I understand your reasoning. I'll give nonetheless both ways a try later this afternoon simply to benchmark my suggestion, but I'll open a PR with your solution :)

pablocostass avatar Oct 25 '20 14:10 pablocostass

The fix about looking at the chunk data is probably something that should be done within OTP to return their own proper type of error on uncoverable modules. Rebar3 should do the catch-and-warn though, IMO.

ferd avatar Oct 26 '20 13:10 ferd