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 5.28.0 crashes in __str__ on Windows x64 #18045

Closed
mtnpke opened this issue Aug 30, 2024 · 7 comments · Fixed by #18159
Closed

Protobuf Python 5.28.0 crashes in __str__ on Windows x64 #18045

mtnpke opened this issue Aug 30, 2024 · 7 comments · Fixed by #18159
Assignees

Comments

@mtnpke
Copy link

mtnpke commented Aug 30, 2024

What version of protobuf and what language are you using?
Version: v5.28.0

Language: Python

What operating system (Linux, Windows, ...) and version?
Windows 11 23H2 Build 22631.4037

What runtime / compiler are you using (e.g., python version or gcc version)
Python 3.12.5 (tags/v3.12.5:ff3bc82, Aug 6 2024, 20:45:27) [MSC v.1940 64 bit (AMD64)] on win32

What did you do?

  • Create Python venv
  • Run pip install protobuf (as of today: installs protobuf 5.28.0)
  • Create test.proto with this content:
syntax = "proto3";

message MyMessage {
    string test = 1;
}
  • Run protoc --python_out=. -I. test.proto
  • Create test.py with this content:
import test_pb2
for i in range(100):
    print(i)
    m = test_pb2.MyMessage()
    print(m)
print("ok")
  • Run python test.py

What did you expect to see
Counting from 0 to 99 and then "ok"

What did you see instead?
Crash at i = 1

image

image

Note: There is no crash with protobuf Python package 5.27.4. Crashing starts with 5.28.0rc1.

Note: If you include an integer field instead of a string, it will not crash, but display random values for the field.

@mtnpke mtnpke added the untriaged auto added to all issues by default when created. label Aug 30, 2024
@aaltat
Copy link

aaltat commented Sep 2, 2024

I am seeing something similar within my project. Update to protobuf broke my test in Windows https://github.com/MarketSquare/robotframework-browser/actions/runs/10608698864/job/29403939266?pr=3765

@liqunfu
Copy link

liqunfu commented Sep 3, 2024

We have same failure with windows build: https://github.com/onnx/onnx/actions/runs/10687189577/job/29624209865?pr=6327

@mkruskal-google mkruskal-google self-assigned this Sep 5, 2024
@mkruskal-google mkruskal-google added upb python and removed untriaged auto added to all issues by default when created. labels Sep 5, 2024
@mkruskal-google
Copy link
Member

I was able to reproduce this using x64 python 3.12.5. I also tried x86 3.12.5 and x64 3.10.4 first and had no luck. So this looks like something very tied to python version we likely missed in our test coverage

@mkruskal-google
Copy link
Member

mkruskal-google commented Sep 5, 2024

It looks like this is only reproducible under all of the conditions:

  1. windows
  2. 64-bit protobuf wheel
  3. optimized build
  4. python 3.12

4 is a little less clear, as our GHA show segfaults under all python versions when I switch to opt

@aaltat
Copy link

aaltat commented Sep 6, 2024

Hmmm, at least on my GitHub actions error is not tied to specific python version, example this uses 3.9 https://github.com/MarketSquare/robotframework-browser/actions/runs/10660730916/job/29545167895?pr=3765

But in the other I have pytest in the picture too

@mtnpke
Copy link
Author

mtnpke commented Sep 6, 2024

I have confirmed this on both 3.11 and 3.12 (both x64); I did not test other versions.

copybara-service bot pushed a commit that referenced this issue Sep 6, 2024
Fixes #18045

This should also cover googleapis/proto-plus-python#483 once we release it.

PiperOrigin-RevId: 671925586
mkruskal-google pushed a commit that referenced this issue Sep 7, 2024
Fixes #18045

This should also cover googleapis/proto-plus-python#483 once we release it.

PiperOrigin-RevId: 671934556
mkruskal-google added a commit that referenced this issue Sep 7, 2024
* upb: fix uninitialized upb_MessageValue buffer bugs

Fixes #18045

This should also cover googleapis/proto-plus-python#483 once we release it.

PiperOrigin-RevId: 671934556

* Regenerate stale files

---------

Co-authored-by: Eric Salo <[email protected]>
@liqunfu
Copy link

liqunfu commented Sep 11, 2024

The issue is not completely fixed. Please fix the wheel at: https://pypi.org/project/protobuf/5.28.0/ before close this issue - create a post release package to override the current one which has the original issue.

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

Successfully merging a pull request may close this issue.

4 participants