Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eventhub: the program crashes if producer not use with with #8404

Closed
davidt99 opened this issue Nov 5, 2019 · 13 comments
Closed

eventhub: the program crashes if producer not use with with #8404

davidt99 opened this issue Nov 5, 2019 · 13 comments
Assignees
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. Event Hubs

Comments

@davidt99
Copy link

davidt99 commented Nov 5, 2019

I'm testing the new version of the SDK. If I'm not surrounding the producer with with statement, after the producer is clean up by the python interpreter, the program just crashes with double free or corruption (fasttop) message.
I do understand that the with statement is required, but this poses a couple of problems:

  1. Python's memory management is done by the interpreter, the developer usually doesn't need to bother when the memory is free, the with statement is there to make sure all of the resources are clean up at the right time but not using it should never cause the program to crash.
  2. My scenario consists of sending single event at a time. I can't reuse the producer when I'm forced to use it with a with statement. Creating new producer takes about 2 seconds so that not an option as well.
@kaerm kaerm added Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. Event Hubs labels Nov 6, 2019
@triage-new-issues triage-new-issues bot removed the triage label Nov 6, 2019
@kaerm
Copy link
Contributor

kaerm commented Nov 6, 2019

@davidt99 thanks for reporting the issue - our team will looking into this as well //cc: @yunhaoling

@YijunXieMS
Copy link
Contributor

Hi @davidt99, thanks for reporting the issue.
In your case, you can close the producer by calling producer.close() when you don't need that producer any more. The "with" statement actually calls this "close" method.
We'll look into cleaning up if no close method is called.
Are you using sync or async EventHubProducerClient?

@YijunXieMS
Copy link
Contributor

@davidt99 were you trying with 5.0.0b4 or 5.0.0b5? We happened to release 5.0.0b5 last night around 9pm PST. So not sure you're talking about 5.0.0b4 or b5. Both are preview versions though.

@mayurid mayurid added this to the [2019] December milestone Nov 6, 2019
@davidt99
Copy link
Author

davidt99 commented Nov 6, 2019

Not using the async, I was just doing a simple test. I was using 5.0.0b4.
At the moment I don't want to keep the producer around without the with statement because of the crash issue in case it gets freed by the GC.

@YijunXieMS
Copy link
Contributor

@davidt99 Then please call producer.close() just before you don't need the producer variable any more.

@davidt99
Copy link
Author

davidt99 commented Nov 7, 2019

@YijunXieMS, yes I understand. As I said, I'll wait for the program crash fix before implementing this in production.

@lmazuel
Copy link
Member

lmazuel commented Nov 21, 2019

After investigation, that's a uamqp issue (azure-eventhub is not doing any crazy things), fix in progress:
Azure/azure-uamqp-python#116

@yunhaoling
Copy link
Contributor

Hello @davidt99 ,

we've released the uamqp v1.2.5 including the fix: https://pypi.org/project/uamqp/1.2.5
can you try installing the latest uamqp library to see the issue still occurs on your side?

@yunhaoling
Copy link
Contributor

Hello @davidt99 , is there any updates for this issue?

@davidt99
Copy link
Author

davidt99 commented Dec 17, 2019 via email

@yunhaoling
Copy link
Contributor

thanks @davidt99 , looking forwarding to your reply!

@davidt99
Copy link
Author

@yunhaoling, using 5.0.0b6, the crash no longer happens, although "Can't call on_state_changed during garbage collection, plase be sure to close or use a context manager" is shown but I guess it makes sense (besides the typo 😉).

@lmazuel
Copy link
Member

lmazuel commented Dec 26, 2019

I take ownership for the typo :p
Azure/azure-uamqp-python#136

Yes, I think this warning if fair. If the client is not closed properly, the message sender/receiver are garbage collected while still open, and because the callback system is define recursively on the class itself, calling a callback on a garbage collected object is not possible.

@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. Event Hubs
Projects
None yet
Development

No branches or pull requests

7 participants