Skip to content

Conversation

@ansd
Copy link
Member

@ansd ansd commented Jul 10, 2025

This commit fixes several crashes:

  1. Serialising IEEE 754-2008 decimals as well as NaN and +-Inf for float and doubles crashed
  2. Converting IEEE 754-2008 decimals as well as NaN and +-Inf for float and dobules from amqp to amqpl crashed

The 2nd crash looks as follows:

exception exit: {function_clause,
                    [{mc_amqpl,to_091,
                         [<<"decimal-32">>,{as_is,116,<<124,0,0,0>>}],
                         [{file,"mc_amqpl.erl"},{line,747}]},
                     {mc_amqpl,'-convert_from/3-lc$^2/1-2-',1,
                         [{file,"mc_amqpl.erl"},{line,155}]},
                     {mc_amqpl,convert_from,3,
                         [{file,"mc_amqpl.erl"},{line,155}]},
                     {mc,convert,3,[{file,"mc.erl"},{line,358}]},
                     {rabbit_channel,outgoing_content,2,
                         [{file,"rabbit_channel.erl"},{line,2649}]},
                     {rabbit_channel,handle_basic_get,7,
                         [{file,"rabbit_channel.erl"},{line,2636}]},
                     {rabbit_channel,handle_cast,2,
                         [{file,"rabbit_channel.erl"},{line,617}]},
                     {gen_server2,handle_msg,2,
                         [{file,"gen_server2.erl"},{line,1056}]}]}

The 2nd crash is fixed by omitting any {as_is, _TypeCode, _Binary} values during AMQP 1.0 -> AMQP 0.9.1 conversion.
This will be documented in the conversion table.

In addition to fixing these crashes, this commit adds tests that RabbitMQ is able to store and forward IEEE 754-2008 decimals. IEEE 754-2008 decimals can be parsed and serialsed by RabbitMQ. However, RabbitMQ doesn't support interpreting this values. For example, they can't be used on the headers exchange or for AMQP filter expressions.

Docs PR:
rabbitmq/rabbitmq-website#2301

@ansd ansd added the bug label Jul 10, 2025
@ansd ansd self-assigned this Jul 10, 2025
@ansd ansd added this to the 4.2.0 milestone Jul 10, 2025
@ansd ansd force-pushed the amqp-decimal branch 2 times, most recently from 76c3153 to 6c59021 Compare July 10, 2025 19:13
This commit fixes several crashes:
1. Serialising IEEE 754-2008 decimals as well as
   NaN and +-Inf for float and doubles crashed
2. Converting IEEE 754-2008 decimals as well as NaN and +-Inf
   for float and dobules from amqp to amqpl crashed

The 2nd crash looks as follows:
```
exception exit: {function_clause,
                    [{mc_amqpl,to_091,
                         [<<"decimal-32">>,{as_is,116,<<124,0,0,0>>}],
                         [{file,"mc_amqpl.erl"},{line,747}]},
                     {mc_amqpl,'-convert_from/3-lc$^2/1-2-',1,
                         [{file,"mc_amqpl.erl"},{line,155}]},
                     {mc_amqpl,convert_from,3,
                         [{file,"mc_amqpl.erl"},{line,155}]},
                     {mc,convert,3,[{file,"mc.erl"},{line,358}]},
                     {rabbit_channel,outgoing_content,2,
                         [{file,"rabbit_channel.erl"},{line,2649}]},
                     {rabbit_channel,handle_basic_get,7,
                         [{file,"rabbit_channel.erl"},{line,2636}]},
                     {rabbit_channel,handle_cast,2,
                         [{file,"rabbit_channel.erl"},{line,617}]},
                     {gen_server2,handle_msg,2,
                         [{file,"gen_server2.erl"},{line,1056}]}]}
```
The 2nd crash is fixed by omitting any `{as_is, _TypeCode, _Binary}`
values during AMQP 1.0 -> AMQP 0.9.1 conversion.
This will be documented in the conversion table.

In addition to fixing these crashes, this commit adds tests that
RabbitMQ is able to store and forward IEEE 754-2008 decimals.
IEEE 754-2008 decimals can be parsed and serialsed by RabbitMQ.
However, RabbitMQ doesn't support interpreting this values. For example,
they can't be used on the headers exchange or for AMQP filter
expressions.
ansd added a commit to rabbitmq/rabbitmq-website that referenced this pull request Jul 10, 2025
@ansd ansd marked this pull request as ready for review July 10, 2025 19:52
ansd added a commit to rabbitmq/rabbitmq-website that referenced this pull request Jul 11, 2025
@ansd ansd merged commit 250be2c into main Jul 11, 2025
559 of 561 checks passed
@ansd ansd deleted the amqp-decimal branch July 11, 2025 08:21
ansd added a commit that referenced this pull request Jul 11, 2025
Fix AMQP crashes for approximate numbers (backport #14209)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants