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

Possibly memory leak and assertion failure in nghttp2_session_pack_data #2104

Open
Jeevhi opened this issue Mar 18, 2024 · 5 comments
Open
Labels

Comments

@Jeevhi
Copy link

Jeevhi commented Mar 18, 2024

I am using libnghttp2 to send APN2 notification. The basic code was taken from https://github.com/nghttp2/nghttp2/blob/master/examples/client.c

The difference is that I keep connection open for sending multiple notifications, but one at a time. Hence I do not call nghttp2_session_terminate_session from on_stream_close_callback. Instead I call nghttp2_session_del when connection is closed by the server.

This worked so far. However, recently our usage increased and I started getting assertion here in nghttp2_session_pack_data function.

https://github.com/nghttp2/nghttp2/blob/master/lib/nghttp2_session.c#L7737

/* Current max DATA length is less then buffer chunk size */
  assert(nghttp2_buf_avail(buf) >= datamax);

Do you think this due to I am not calling nghttp2_session_terminate_session. What would be right way to handle this?

Thanks

@Jeevhi Jeevhi changed the title Possibly memory leak or api usage issue Possibly memory leak and assertion failure in nghttp2_session_pack_data Mar 19, 2024
@Jeevhi
Copy link
Author

Jeevhi commented Mar 21, 2024

I see many unanswered issues here so wondering if issues here are watched or do we need to post in some other forum. thanks

@tatsuhiro-t
Copy link
Member

Watched but the issue like this is hard to deal with because it may be a bug in your program. Most likely you are calling nghttp2_session from multiple threads or something. There are many users, but the person that answers their countless questions is just me.

@Jeevhi
Copy link
Author

Jeevhi commented Mar 21, 2024

I understand and appreciate. thanks for answering.

nghttp2_session is being used from multiple threads but as mentioned, only one request at a time and each request is protected by mutex and hence there is no contention or no two threads accessing it simultaneously. Is accessing nghttp2_session from multiple thread even is an issue even when protected by mutex.

In addition, if you can guide me here, does calling nghttp2_session_del releases all the resourses if nghttp2_session_terminate_session not called at all?

@tatsuhiro-t
Copy link
Member

In addition, if you can guide me here, does calling nghttp2_session_del releases all the resourses if nghttp2_session_terminate_session not called at all?

Yes. Calling nghttp2_session_terminate_session is optional.

Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale label May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants