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

@grpc/grpc-js: Closing Stream After Unary Call Triggers Double Free #1464

Closed
moloch-- opened this issue Jun 7, 2020 · 9 comments
Closed

Comments

@moloch--
Copy link

moloch-- commented Jun 7, 2020

Problem description

Attempting to close the client's connections to a server after making a single unary call triggers a panic in Node (this may actually be a bug in Node, it's not clear to me).

Reproduction steps

I have a client class that manages a couple gRPC streams (_events and _tunnelStream) that are open for the lifetime of the client class. The client also makes unary calls. After making any number of unary calls (1 or more), and attempting to disconnect with the function below triggers a double free what appears to be the NodeJS HTTP/2 library:

  async disconnect(): Promise<void> {
    if (this._events !== null) {
      this._events.on('error', () => {})
      this._events.cancel()
    }
    if (this._tunnelStream !== null) {
      this._tunnelStream.on('error', () => {})
      this._tunnelStream.cancel()
    }
    this.rpc.close()
  }

Environment

  • MacOS / Ubuntu 20.04
  • Node version 14
  • Package name and version @grpc/grpc-js ^1.0.3

Screenshots

Screen Shot 2020-06-07 at 10 59 01 AM

Screen Shot 2020-06-07 at 8 18 13 AM

@murgatroid99
Copy link
Member

That is definitely a bug in Node itself. You have more information about how you triggered the bug and your environment, so you should file an issue in that repository (https://github.com/nodejs/node), and link to it from here. I suggest that when you do, you share the error information in the form of text so that it's easier to interact with.

@sangaman
Copy link
Contributor

Is there any update on this? I think I've encountered the same issue, still trying to figure out how to deal with it.

@LePremierHomme
Copy link

Wrapping the .cancel() call with setTimeout/setImmediate seems to mitigate the error.

@mdouglass
Copy link
Contributor

@murgatroid99 built a small repro case for this issue and opened a ticket against https://github.com/nodejs/node as suggested.

@bl-ue
Copy link

bl-ue commented Jun 8, 2021

nodejs/node#38964. I'll investigate it.
As long as you guys aren't using any C/C++ modules, it's definitely a bug in Node.

@murgatroid99
Copy link
Member

grpc-js definitely doesn't use any C/C++ modules. Avoiding them was the main reason the library was created.

@bl-ue
Copy link

bl-ue commented Jun 8, 2021

Great, okay, it like it's definitely a bug in node core. Track nodejs/node#38964 for updates :)

@bl-ue
Copy link

bl-ue commented Jun 20, 2021

Linking for reference 🎉 nodejs/node#39076 — thank you @mdouglass!!

raksooo added a commit to mullvad/mullvadvpn-app that referenced this issue Nov 2, 2021
This is a workaround for grpc/grpc-node#1464
which is a bug were canceling the stream just before closeing the gRPC
connection causes a segfault.
raksooo added a commit to mullvad/mullvadvpn-app that referenced this issue Nov 2, 2021
This is a workaround for grpc/grpc-node#1464
which is a bug were canceling the stream just before closeing the gRPC
connection causes a segfault.
raksooo added a commit to mullvad/mullvadvpn-app that referenced this issue Nov 2, 2021
This is a workaround for grpc/grpc-node#1464
which is a bug were canceling the stream just before closeing the gRPC
connection causes a segfault.
@murgatroid99
Copy link
Member

This is a Node bug and it appears to have been fixed in Node.

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

No branches or pull requests

6 participants