Exception thrown when using socket sets

kat123 wrote on Monday, February 05, 2018:

SocketSet_t xFD_set;
xFD_set = FreeRTOS_CreateSocketSet(4);
FreeRTOS_FD_SET(xUDPSocket, xFD_set, eSELECT_READ);
FreeRTOS_select(&xFD_set, pdMS_TO_TICKS(500));

I’ve set up a socket set with the code above and when I reach the select function an exception is thrown( read access violation, line 532 of event_groups.c).
I’m running this on the win32 simulator using Visual Studio.

I don’t understand what is happening in the code where the exception is thrown.
Is there anything about this set up that would cause the exception?

rtel wrote on Monday, February 05, 2018:

Comparing to the example code on
https://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_UDP/API/select.shtml
I notice two strange things in your code:

FreeRTOS_FD_SET(xUDPSocket, xFD_set, eSELECT_READ);

FreeRTOS_FD_Set() only has two parameters but you are passing three.
See
https://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_UDP/API/FD_SET.shtml

FreeRTOS_select(&xFD_set, pdMS_TO_TICKS(500));

The first parameter to FreeRTOS_select() passing is the xFD_Set variable
directly, whereas you are passing in the address of the variable - that
is most likely the cause of the exception.

I would recommend ensuring the code, as far as possible, builds without
any compiler warnings.