[Libwebsockets] Access violation

Ake Hedman, Grodans Paradis AB akhe at grodansparadis.com
Tue Sep 2 22:59:39 CEST 2014


Hi,

I have libwebsocket code (a c++ program) that works on linux but gives 
an Access violation on windows.  I have tried to find the cause for this 
since yesterday now but am dead stuck.

The Access violation is thrown in

    pcontext = libwebsocket_create_context( &info );

which is initialized with

     struct lws_context_creation_info info;
     memset( &info, 0, sizeof( info ) );

     info.port = m_portWebsockets;
     info.iface = NULL; // websockif;
     info.protocols = websocket_protocols;
     info.extensions = libwebsocket_get_internal_extensions();
     //info.ssl_ca_filepath = NULL;
     info.ssl_cert_filepath = NULL;
     //info.ssl_cipher_list = NULL;
     info.ssl_private_key_filepath = NULL;
     info.gid = -1;
     info.uid = -1;
     info.options = websocket_opts;
     info.user = NULL;
     info.ka_time = 0;
     info.ka_probes = 0;
     info.ka_interval = 0;

     info.token_limits = NULL;
     info.ssl_private_key_password = NULL;
     info.ssl_cert_filepath = NULL;
     info.ssl_private_key_filepath = NULL;
     info.ssl_ca_filepath = NULL;
     info.ssl_cipher_list = NULL;
     info.http_proxy_address = NULL;

(yes I know it's some doublets here)

and the websocket_protocols

     static struct libwebsocket_protocols websocket_protocols[] = {

     // first protocol must always be HTTP handler

     {
         "http-only",                            // name
         CControlObject::callback_http,            // callback
         sizeof(struct per_session_data__http),    // per_session_data_size
         0, // max frame size / rx buffer
     },
     {
         "dumb-increment-protocol",
         CControlObject::callback_dumb_increment,
         sizeof( struct per_session_data__dumb_increment),
         10,
     },
     {
         "lws-mirror-protocol",
         CControlObject::callback_lws_mirror,
         sizeof(struct per_session_data__lws_mirror),
         128,
     },
     {
         "very-simple-control-protocol",
         CControlObject::callback_lws_vscp,
         sizeof( struct per_session_data__lws_vscp),
         128,
     },
     {
         NULL, NULL, 0, 0 // End of list
     }
};

The methods are static.

I have debugged the code and I see that the  the fault is in line 251 of 
context.c

         /*
          * inform all the protocols that they are doing their one-time
          * initialization if they want to
          */
info->protocols[context->count_protocols].callback(context,
                    NULL, LWS_CALLBACK_PROTOCOL_INIT, NULL, NULL, 0);

when the PROTOCOL_INIT is sent to the second supported protocol. I I 
look at the protocol name and the other data it looks as it is just 
trash in the second entry. If I check the same data at the calling point 
it is OK.

This is the the situation I would go to a fellow programmer in the next 
box at the office but here I have none. Does anyone have a 
suggestion/pointer or whatever on what can be the cause of this.

Cheers
/Ake

-- 
Be Hungry - Stay Foolish!
Åke Hedman, Grodans Paradis AB
Brattbergavägen 17, 82050 LOS, SWEDEN
Phone: +46 (0)840011835 CellPhone: +46 (0)730-533146
http://www.grodansparadis.com http://www.vscp.org




More information about the Libwebsockets mailing list