dora-rs / dora

DORA (Dataflow-Oriented Robotic Application) is middleware designed to streamline and simplify the creation of AI-based robotic applications. It offers low latency, composable, and distributed dataflow capabilities. Applications are modeled as directed graphs, also referred to as pipelines.
https://dora-rs.ai
Apache License 2.0
1.36k stars 69 forks source link

C api bug #577

Open starlitxiling opened 4 days ago

starlitxiling commented 4 days ago

When I use the C API, I find that some unpredictable id appear in read_dora_input_id, and it will be the same string I create after that. If I don't create it after that, it will be a segment of id plus a strange hexadecimal number (like BCAG). I think there is a pointer error phenomenon. I don't know if this is related to #540 12ff8c64e23d5bbef8f51c26de7bd50

starlitxiling commented 4 days ago

if you want to reproduce my problem, you can refer this:https://github.com/dora-rs/autoware.universe/tree/feature/autoware_dora/tools/read_id_test

XxChang commented 1 day ago

Because String does not contain \0 char (nul terminator) which is very different from C-string.

You can push a '\0' at this line to see how these been changed. https://github.com/dora-rs/dora/blob/01c404710bd77b758c20ac179ca6e0a3d6705324/libraries/core/src/config.rs#L86-L90

 impl From<String> for DataId { 
     fn from(id: String) -> Self { 
         let mut id = id;
         id.push('\0');
         Self(id) 
     } 
 }
XxChang commented 17 hours ago

by the way, please use strncmp for possibly null-terminator string instead of strcmp

starlitxiling commented 11 hours ago
 impl From<String> for DataId { 
     fn from(id: String) -> Self { 
         let mut id = id;
         id.push('\0');
         Self(id) 
     } 
 }

I tried this, but it fails when parsing dataflow.yml. I think pushing 0 directly will cause many problems.

XxChang commented 11 hours ago

Or learn from https://github.com/eclipse-zenoh/zenoh-c/blob/775e66586d105cbb42882ace58286f0cb2d967b2/src/commons.rs#L551-L568

I thing that let user release id-string is error-prone.