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

cpython.c function signatures may trigger stack corruption on Windows #182

Open
dw opened this issue Jul 1, 2018 · 0 comments
Open

cpython.c function signatures may trigger stack corruption on Windows #182

dw opened this issue Jul 1, 2018 · 0 comments
Labels

Comments

@dw
Copy link
Collaborator

dw commented Jul 1, 2018

Affected Operating Systems

  • Windows
  • [Other]

Affected py-lmdb Version

master

Describe Your Problem

cpython.c makes quite liberal use of METH_NOARGS, which causes the PyCFunction pointer to be invoked as (*meth)(self, NULL), however most of our METH_NOARGS functions are delcared as PyObject *func(PyObject *self), i.e. lacking the second parameter.

In calling conventions where the caller is responsible for stack cleanup (such as on Linux) this won't break, however on Windows, where the callee is responsible for cleaning up the stack, there is potential for the stack to become inconsistent for each call to any of our METH_NOARGS functions.

This doesn't seem to have ever generated a bug report - and I'm not even sure what such a bug report would look like, however the problem is real.

The simple solution is to add a second dummy PyObject parameter to every METH_NOARGS function, and double-check the rest of our signatures to see if a similar problem exists elsewhere.

I'm happy to take this ticket when I have a free moment :)

@dw dw added the bug label Jul 1, 2018
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

1 participant