processone / xmpp

Erlang/Elixir XMPP parsing and serialization library on top of Fast XML

Home Page:http://process-one.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Crash running "make spec" with Erlang 26

badlop opened this issue · comments

commented

This xmpp library uses fast_xml when running make spec.

Since Erlang/OTP 26.0, this fails:

$ erl -version
Erlang (SMP,ASYNC_THREADS) (BEAM) emulator version 14.0.2

$ REBAR=rebar3 make spec
erl -noinput +B -pa ebin -pa _build/default/lib/*/ebin -eval \
'case fxml_gen:compile("specs/xmpp_codec.spec", [{add_type_specs, xmpp_element}, {erl_dir, "src"}, {hrl_dir, "include"}]) of ok -> halt(0); _ -> halt(1) end.'
failed to compile "specs/xmpp_codec.spec": {'EXIT',
                                            {badarg,
                                             [{ets,lookup_element,
                                               [{dict,0,16,16,8,80,48,
                                                 {[],[],[],[],[],[],[],[],[],
                                                  [],[],[],[],[],[],[]},
                                                 {{[],[],[],[],[],[],[],[],[],
                                                   [],[],[],[],[],[],[]}}},
                                                jid,2,error],
                                               [{error_info,
                                                 #{cause => type,
                                                   module =>
                                                    erl_stdlib_errors}}]},
                                              {erl_types,lookup_module_types,
                                               3,
                                               [{file,"erl_types.erl"},
                                                {line,5196}]},

The function called by fast_xml that worked previously and now fails:

This worked:

$ erl
Erlang/OTP 25 [erts-13.2.2.1] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [jit:ns]

Eshell V13.2.2.1  (abort with ^G)
1>     erl_types:t_from_form(
1>        {remote_type,5184,[{atom,5184,jid},{atom,5184,jid},[]]},
1>                sets:new(),
1>                {type, {mod, foo, 1}, "mod.erl"},
1>                dict:new(),
1>        erl_types:var_table__new(),
1>                erl_types:cache__new()).
{any,{cache,#{},
            {mrecs,{dict,0,16,16,8,80,48,
                         {[],[],[],[],[],[],[],[],[],[],[],[],[],[],...},
                         {{[],[],[],[],[],[],[],[],[],[],[],[],...}}}}}}

But now it fails:

$ erl
Erlang/OTP 26 [erts-14.0.1] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [jit:ns]

Eshell V14.0.1 (press Ctrl+G to abort, type help(). for help)
1>     erl_types:t_from_form(
..        {remote_type,5184,[{atom,5184,jid},{atom,5184,jid},[]]},
..                sets:new(),
..                {type, {mod, foo, 1}, "mod.erl"},
..                dict:new(),
..        erl_types:var_table__new(),
..                erl_types:cache__new()).
** exception error: bad argument
     in function  ets:lookup_element/4
        called as ets:lookup_element({dict,0,16,16,8,80,48,
                                           {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
                                           {{[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]}}},
                                     jid,2,error)
        *** argument 1: not an atom or a table identifier
     in call from erl_types:lookup_module_types/3 (erl_types.erl, line 5196)
     in call from erl_types:remote_from_form/8 (erl_types.erl, line 4623)
     in call from erl_types:t_from_form2/5 (erl_types.erl, line 4287)

The problem seems to be that fast_xml calls an internal, undocumented module erl_types from Erlang/OTP dialyzer, and that one changed in Erlang 26 its data storage from dict to map in erlang/otp@5732196

Which calls an ets BIF function added in erlang/otp@e528e26

I took a look attempting to improve fast_xml to support the new erl_types.erl, but I didn't succeed. As a temporary workaround, I'll disable running make spec with newer Erlang 26 in the CI tests.

Should be fixed in processone/fast_xml@bbd1de1 , but I'm not sure if the problem appeared in OTP 25 or 26 first.

Right, it works now when using your fixed fast_xml. Thanks!