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

Segmentation fault on accessing const char *send_data in static PyObject *frame_data(PyObject *self, PyObject *args) #55

Open
rlbjorn opened this issue Jun 26, 2024 · 1 comment
Labels
bug New bug macos Apple macOS platform support issues

Comments

@rlbjorn
Copy link

rlbjorn commented Jun 26, 2024

static PyObject *frame_data(PyObject *self, PyObject *args) and static PyObject *get_data(PyObject *self, PyObject *args) both declare a const char* array which PyArg_ParseTuple is supposed to populate. The behavior seems undefined as this works on my windows computer, but not on the mac.

Allocating a size for the c arrays fixes the issue, f.ex:
const char send_data[255]; instead of const char *send_data

@rlbjorn
Copy link
Author

rlbjorn commented Jun 26, 2024

I got it working correctly on both arm mac and windows by using the safer specifer z#, instead of s# in
if (!PyArg_ParseTuple(args, "z#|II", &send_data, &data_length, &frame_type, &seq_no)) and
if (!PyArg_ParseTuple(args, "z#", &frame_data, &buf_length))

using Py_ssize_t for buf_length/data_length

z# actually allocates the memory if i understood it correctly, while s# does not.

@SkypLabs SkypLabs added bug New bug macos Apple macOS platform support issues labels Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug New bug macos Apple macOS platform support issues
Projects
None yet
Development

No branches or pull requests

2 participants