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

Protobuf Python extension module is not ABI compatible with Stackless Python #6094

Closed
akruis opened this issue May 2, 2019 · 3 comments
Closed
Assignees
Labels

Comments

@akruis
Copy link

akruis commented May 2, 2019

What version of protobuf and what language are you using?
Version: any version, that uses the CPP extension module i.e. 3.7.1
Language: Stackless Python

What operating system (Linux, Windows, ...) and version?
Not relevant

What runtime / compiler are you using (e.g., python version or gcc version)
Not relevant

What did you do?
Steps to reproduce the behavior:

  1. Install Stackless Python 3.7.3
  2. install protobuf 3.7.1 wheel
    $ python -m pip install protobuf
  3. run the following python code (minimal example)
    from google.protobuf.pyext import _message
    def func():
        _message.Message._CheckCalledFromGeneratedFile()
    func()
    

What did you expect to see

TypeError: Descriptors should not be created directly, but only retrieved from their parent.

What did you see instead?

Segmentation fault (core dumped)

Anything else we should know about your project / environment

The segmentation fault is caused by the following line of code:

if (frame->f_code->co_filename == NULL) {

The problem is, that protobuf uses the structure PyFrameObject (frame->f_code) which is not part of the C-Python ABI and differs between C-Python and Stackless Python. See https://github.com/stackless-dev/stackless/wiki/Portable-usage-of-PyFrameObject for details.

Merging pull request #5171 would fix the problem.

Another option is compute the offset of the field f_code at runtime. Use the macro PYFRAME_CODE(frame) from https://github.com/stackless-dev/stackless/wiki/Portable-usage-of-PyFrameObject.

Work arounds

  1. Install the pure Python version of protobuf or
  2. Compile protobuf using Stackless Python
@anandolee
Copy link
Contributor

I think #5171 owner may not working on the PR anymore. I will remove _CheckCalledFromGeneratedFile() in another change later.

@BSBandme BSBandme added the python label May 8, 2019
@snoopy-coder
Copy link

snoopy-coder commented Jan 13, 2020

I recently encountered an error while using Protobuf Python extension module.
tdryer/hangups#451 (comment)
Not sure it is relevant to this discussion, but I consider it necessary to inform you.

@haberman
Copy link
Member

haberman commented Feb 1, 2024

Closing as obsolete. The relevant APIs (eg. _CheckCalledFromGeneratedFile) have been removed.

@haberman haberman closed this as completed Feb 1, 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

5 participants