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

[MODULES] Calling RedisModule_WrongArity from a thread-safe context crashes redis #4756

Open
dvirsky opened this issue Mar 15, 2018 · 5 comments

Comments

@dvirsky
Copy link
Contributor

dvirsky commented Mar 15, 2018

To reproduce:

  1. Block the client.
  2. Create a thread safe context from the blocked client.
  3. Call RedisModule_WrongArity(ctx)

The reason is that the function does the following:

 addReplyErrorFormat(ctx->client,
        "wrong number of arguments for '%s' command",
        (char*)ctx->client->argv[0]->ptr);

and we do not have argv at this point.
I think the simplest thing to do would be to keep a pointer to the command name (with incrRef) directly in the context and not rely on argv and the client. It might come in handy in other places as well.

@dvirsky
Copy link
Contributor Author

dvirsky commented Mar 15, 2018

cc: @mnunberg if you have anything to add to this...

@mnunberg
Copy link
Contributor

mnunberg commented Mar 15, 2018 via email

@dvirsky
Copy link
Contributor Author

dvirsky commented Mar 15, 2018 via email

@jonahharris
Copy link
Contributor

Agreed. @dvirsky can you share your exact example case. I want to run some tests on different methods regarding the fix.

@dvirsky
Copy link
Contributor Author

dvirsky commented Mar 16, 2018

@jonahharris I don't have anything ATM, we had it in redisearch but fixed it. You can modify the module examples in the redis source tree to reproduce this pretty easily. try helloblock.c I think.

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

4 participants