Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Segmentation fault error during federated execution caused by multiport #25

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions lib/pythontarget.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,11 +412,8 @@ void destroy_action_capsule(PyObject* capsule) {
* Individual ports can then later be accessed in Python code as port[idx].
*/
PyObject* convert_C_port_to_py(void* port, int width) {
generic_port_instance_struct* cport;
if (width == -2) {
// Not a multiport
cport = (generic_port_instance_struct *)port;
}
generic_port_instance_struct* cport = (generic_port_instance_struct *)port;

Comment on lines +415 to +416
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if the intended design was to keep this as-is, and to wrap line 433 (FEDERATED_ASSIGN_FIELDS) in if (width == -2). Just guessing since it seems like cport is only being used when the port is not a multiport.

In fact it might have been clearer to move all of the code that touches cport into the branch at line 435-448.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with Peter here. The proposed cast doesn't look correct for a multiport, and, although it is probably harmless, it seems misleading.

// Create the port struct in Python
PyObject* cap =
(PyObject*)PyObject_GC_New(generic_port_capsule_struct, &py_port_capsule_t);
Expand Down