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 (core dumped),when using devsdk_post_readings function to deliver a json message #464

Closed
yeehecan opened this issue Jun 30, 2023 · 1 comment · Fixed by #470
Assignees
Labels
bug Something isn't working question Further information is requested

Comments

@yeehecan
Copy link

yeehecan commented Jun 30, 2023

Hi all:
I tried to using devsdk_post_readings function to deliver some json message,but get a Segmentation fault (core dumped)

I debug into device-sdk-c source , The error occurs in bus.c at line 101 , during the 'edgex_bus_post' function building the message envelope and setting the 'correlationID' property , It seems that edgex_device_get_crlid () always return NULL.

i added some code to check if the edgex_device_get_crlid () returns null , and replace it with a uuid if empty ,problem solved, but I don't know if it will have any other impact.

i`m using a ubuntu22.04 docker container as the development environment. and device-csdk-c version 3.0.0

gdb debug message:
(gdb) bt
#0 0x00007f195a834a7c in pthread_kill () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x00007f195a7e0476 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#2 0x00007f195a7c67f3 in abort () from /lib/x86_64-linux-gnu/libc.so.6
#3 0x00007f195a7c671b in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#4 0x00007f195a7d7e96 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
#5 0x00007f195aaaad39 in iot_data_alloc_string (val=0x0, ownership=IOT_DATA_REF) at /workspace/src/device-sdk-c/src/iotech-c-utils/src/c/data.c:1403
#6 0x00007f195aadcd51 in edgex_bus_post (bus=0x558f66d108c0,
path=0x558f66d28310 "edgex/events/device/device-iec104-msater/lensyn-iec104-master/104_slave_1/JSON", payload=0x558f66d2e1c0)
at /workspace/src/device-sdk-c/src/c/bus.c:101
#7 0x00007f195aae3956 in edgex_data_client_add_event (client=0x558f66d108c0, ev=0x558f66d2d550, metrics=0x558f66d10510)
at /workspace/src/device-sdk-c/src/c/data.c:190
#8 0x00007f195ab014e7 in devsdk_post_readings (svc=0x558f66d10320, devname=0x558f6537b358 "104_slave_1", resname=0x558f6537b353 "JSON", values=0x7ffc3173adb0)
at /workspace/src/device-sdk-c/src/c/service.c:1057
#9 0x0000558f65362eba in main (argc=1, argv=0x7ffc3173af78) at /workspace/src/device-iec104-master.c:628

Has anyone had the same problem,Help me.

I have poor English , I don't know if it's clearly expressed, sorry。

@yeehecan yeehecan added the question Further information is requested label Jun 30, 2023
@iain-anderson
Copy link
Member

yes, that looks to be the problem. devsdk_post_readings() needs to call edgex_device_alloc_crlid (NULL) before pushing the event, and edgex_device_free_crlid () afterwards.

@iain-anderson iain-anderson added the bug Something isn't working label Jun 30, 2023
@FelixTing FelixTing self-assigned this Jul 14, 2023
FelixTing added a commit to FelixTing/device-sdk-c that referenced this issue Jul 18, 2023
FelixTing added a commit to FelixTing/device-sdk-c that referenced this issue Jul 20, 2023
FelixTing added a commit to FelixTing/device-sdk-c that referenced this issue Jul 20, 2023
fix edgexfoundry#464

Also update the file monitor example to v3

Signed-off-by: FelixTing <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants