NVIDIA / go-dcgm

Golang bindings for Nvidia Datacenter GPU Manager (DCGM)
Apache License 2.0
96 stars 27 forks source link

Segfault using result of FieldValue_v1.String() #18

Closed bmerry closed 2 years ago

bmerry commented 2 years ago

While trying to implement https://github.com/NVIDIA/dcgm-exporter/issues/72 I've encountered a segfault when trying to use DCGM_FI_DRIVER_VERSION; specifically if I try to format the result of FieldValue_v1.String().

I've only written a few hundred lines of Go in my life, but this looks suspicious: it's directly casting a C NUL-terminated string to a Go string, rather than using C.GoString.

nikkon-dev commented 2 years ago

Hi @bmerry,

Thank you for the report!

Yes, you are right, that's a bug. As you could see from several lines below, the strings are should be handled differently.

glowkey commented 2 years ago

Fixed with MR#19