Undefined method "method_class" for AMQ::Protocol::BodyFrame #218

Closed
alexnorthsoul opened this Issue Sep 30, 2015 · 12 comments

Projects

None yet

5 participants

@alexnorthsoul

Hello, guys

unfortunately, there's a bug

undefined method `method_class' for #<AMQ::Protocol::BodyFrame:0x0000001e8a60b0>

ruby/2.1.0/gems/amqp-1.5.0/lib/amqp/session.rb:1112:in `frameset_complete?'
ruby/2.1.0/gems/amqp-1.5.0/lib/amqp/session.rb:932:in `receive_frame'
ruby/2.1.0/gems/amqp-1.5.0/lib/amqp/session.rb:671:in `receive_data'
ruby/2.1.0/gems/eventmachine-1.0.4/lib/eventmachine.rb:187:in `run_machine

Here's a line, which raises an exception:

first_frame.final? || (first_frame.method_class.has_content? && content_complete?(frames[1..-1]))

in case, when first_frame.final? evaluates to false.

This happens if first_frame is a HeaderFrame or a BodyFrame

@Inanepenguin

@alexnorthsoul in what context does this happen? A BodyFrame is not supposed to be the first frame in the buffer (from my understanding). I was fighting this issue myself today.

For me, an exception was thrown on the callback block of the first message received, causing the channel's buffer to not be cleared by this line:

clear_frames_on(frame.channel) if @frames[frame.channel]

in #receive_frame. So each subsequent message received on that channel would call first_frame.method_class on the leftover BodyFrame.

I was about to submit an issue myself but just saw yours.

My thought is that #receive_frameset should have some sort of assurance of cleanup. Even if one of my messages blows out the top of the call stack, AMQP shouldn't leave itself in a bad state.

Anywhere you call user specified code without a guaranteed cleanup there can be bugs like the one outlined above.

@michaelklishin
Member

@Inanepenguin's hypothesis sounds realistic

@Inanepenguin

@michaelklishin any chance the "graceful cleanup" in #receive_format could make it in? I can look into trying to submit a PR, I'd have to come up to speed on the style/best practice for the repo. Like I said, I was about to open an issue myself as this just happened to me today. Very coincidental timing!

@michaelklishin
Member

Feel free to submit a PR, thank you.

On 1 oct 2015, at 11:32, Peter Wilson notifications@github.com wrote:

@michaelklishin any chance the "graceful cleanup" in #receive_format could make it in? I can look into trying to submit a PR, I'd have to come up to speed on the style/best practice for the repo. Like I said, I was about to open an issue myself as this just happened to me today. Very coincidental timing!


Reply to this email directly or view it on GitHub.

@jsonn jsonn pushed a commit to jsonn/pkgsrc that referenced this issue Oct 17, 2016
taca Update ruby-amqp to 1.6.0.
## Changes Between 1.5.x and 1.6.0 (Apr 4th, 2016)

### amq-protocol Update

Minimum `amq-protocol` version is now `2.0.1`.

### Provide More Details in TCP Connection Failure Exception

Contributed by Neil Hooey.

GH issue: [#222](ruby-amqp/amqp#222).


### Ensures frameset is cleared after an unhandled exception

Ensures frameset is cleared after an unhandled exception.
This avoids confusing exceptions such as

```
undefined method `method_class' for #<AMQ::Protocol::BodyFrame:0x0000001e8a60b0>
```

Contributed by Michael Lutsiuk.

GH issue: [#218](ruby-amqp/amqp#218)
43728a4
@relonger

The issue is still exists in gem 1.6.0 but solved in 1.5.1. Do you plan to update 1.6.x gem ?

@michaelklishin
Member

@relonger that's curious. What specific commit is in 1.5.x-stable but not master? Happy to release a new 1.6.x version later today or tomorrow.

@relonger

This commit dd0b2de seems to solve the problem.

@michaelklishin
Member

@relonger I cherry-picked 02a9298 to master, please give it a try.

@maattdd
maattdd commented Feb 2, 2017

Could you release a 1.6.1 with this commit included ?

@michaelklishin
Member

@maattdd do you confirm that the issue is gone in master?

@maattdd
maattdd commented Feb 2, 2017

@michaelklishin yes I confirm this bug is in 1.6.0 but fixed in master.

@michaelklishin
Member
michaelklishin commented Feb 2, 2017 edited

@maattdd I released a 1.7.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment