lcm-proj / lcm

Lightweight Communications and Marshalling
GNU Lesser General Public License v2.1
944 stars 385 forks source link

Mac MemoryError caused by interpreting _lcm_eventlog_event_t's datalen and channellen as 64 bit #434

Closed drmoose closed 1 year ago

drmoose commented 1 year ago

The Py_BuildValue format string specification being used in pyeventlog.c, "y#" expands to a char * and a Py_ssize_t parameter. The values passed in at the corresponding va_arg positions are char* and int32_t, respectively.

On Intel Macs, int32_t is not aligned to the same 64-bit boundary as Py_ssize_t, making this an invalid cast.

The symptom is a MemoryError which occurs when trying to read_next_event()

python3 -c 'import lcm; lcm.EventLog("path-to-an-event.log").read_next_event()'

The problem has been demonstrated by @ihilt with a CI pipeline based on this commit.

This PR widens the channellen and datalen before passing them into Py_BuildValue.