[erlang-questions] Runtime crash vs. failed internal consistency check

Andreas Hillqvist andreas.hillqvist@REDACTED
Fri Jan 11 08:56:11 CET 2008


>From the Erlang/OTP bit-syntax documentation:
  Type= integer | float | binarybytes | bitstring | bits
    The default is integer, bytes is a shorthand for binary and bits
is a shorthand for bitstring

Erlang assumes that your variable contains an Integer.
AFAIK Erlang dose not implicitly convert binarys to integers.
I guess it should have been reported as badarg/type mismatch error.

The "correct" code should be something like:
    find_9(<<_:16, Buffer/binary>>) -> Buffer.
Or:
    find_9(<<_:16, Buffer/binary>>) -> <<Buffer/binary>>.


Regards
Andreas Hillqvist

2008/1/10, Attila Babo <babo.online@REDACTED>:
> find_9(<<_:16, Buffer/binary>>) -> <<Buffer>>.
>
> This silly line of code cause an "Internal consistency check failed" error
> message in R12B:
>
> find9: function find_9/1+9:
>   Internal consistency check failed - please report this bug.
>   Instruction: {bs_put_integer,{f,0},
>                                {integer,8},
>                                1,
>                                {field_flags,[unsigned,big]},
>                                {x,0}}
>   Error:       {match_context,{x,0}}:
>
> This message is a huge improvement, as the same code compiles in R11B6, but
> causing a runtime crash:
>
> ** exited:
> {badarg,[{find9,find_9,1},{shell,exprs,6},{shell,eval_loop,3}]}
> **
>
> Am I correct when suspecting that R12B tries to truncate the binary to a
> single byte?
>
> Attila
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>



More information about the erlang-questions mailing list