robert-burger / libethercat

EtherCAT master library. This library is used to build a deterministic fieldbus network with EtherCAT components.
https://www.dlr.de/rm
Other
21 stars 6 forks source link

fix(build_so): Make anon_cb an explicit function in dc.c #6

Closed marcfir closed 6 months ago

marcfir commented 6 months ago

Linking against a shared library produced segfaults because the function pointer was not in a valid address space. Making the function explicit fixed the problem.

robert-burger commented 6 months ago

I did a short test but could not reproduce a segfault here. Does this still occur after you fixed your timeout problems?

As long as the execution of the function is ongoing it should be fine. Only if there's a timeout the function will exit and anon_cb will become invalid. If the frame returned/is beeing processed afterwards it will/may crash. So i agree this might be a problem here, so i think this can be merged.

marcfir commented 6 months ago

Hi Robert, I was finally able to test it. The segmentation error does not go away after fixing the timing problem. I could not find the difference between the Rust FFI link and the C link, but the PR fixes the problem.