CGo : The arrays passed have some elements referring to a large number (~250 digits), prolly due to wrong address reference. #40474
Labels
FrozenDueToAge
WaitingForInfo
Issue is not actionable because of missing required information, which needs to be provided.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I'm running a Go server in which I'm using CGo to call my C functions. The parameters are being passed correctly.
A 'weights' array was assigned in the golang part and sent to the C function as parameter as a pointer in the following way:
result := *C.myFxn( (*C.double)(&myWeights[0]) )
I've checked the array is passed correctly as expected.
Now whenever I start the server, mostly for the first request everything works fine. But for the 2nd and succeeding requests, there comes these issue in the C code.
The weights[i] values are equal to 0. So I check if they are not equal to zero in the 'if' condition.(See the img):
What did you expect to see?
(i) The code shouldn't have entered the if condition, so no lines would've printed for any times i make requests.
What did you see instead?
(i) The code enters the if condition and the print statement is executed. Infact, The weights[i] in the print statement print out as 0. Again if they're zero, these shouldn't have entered the if condition.
Also some of the weights[i] which are 0 are printed out as a very large number(~250 digits).
I feel like this is some address reference issue in CGo (that's why that large number sometimes). I guess many others must have faced a similar issue in CGo as well.
The text was updated successfully, but these errors were encountered: