[Libwebsockets] Segfault after doing lws_ring_insert

prelag at yahoo.com prelag at yahoo.com
Wed Aug 5 22:27:47 CEST 2020

On Wednesday, August 5, 2020, 03:36:28 PM EDT, prelag at yahoo.com <prelag at yahoo.com> wrote: 

The only weird thing that is happening now is in:

static void
__minimal_destroy_message(void *_msg)
    struct msg *msg = (struct msg *) _msg;

    msg->payload = NULL;
    msg->len = 0;

free(): invalid pointer: 0xb755f880

Not sure how that is possible because nothing else is freeing that pointer.  Any suggestions.

Thanks again for your help.

Paul Roberts

On Wednesday, August 5, 2020, 02:48:46 PM EDT, Andy Green <andy at warmcat.com> wrote: 

It's looking good now.  Thanks again!

On 8/5/20 7:37 PM, prelag at yahoo.com wrote:
> Hello,
> Thanks in advance!  I know this is something simple I am overlooking.
> I have a test program based on the client echo example.  I am attempting to create a message and insert it into the ring_buffer to get picked up on the next LWS_CALLBACK_CLIENT_WRITEABLE.
> Here is my simple function that is called when a message is ready to be put in the buffer:
> void MyClass::sendResponse(string &response) {
>      syslog(LOG_DEBUG, "MyClass::sendResponse %s", response.c_str());
>      int len = strlen(response.c_str() + LWS_PRE);
>      msg3.payload = malloc(len);

You're writing beyond what you allocated-->

>      memcpy((char *) msg3.payload + LWS_PRE, response.c_str(), len);

None of that is any lws issue.


More information about the Libwebsockets mailing list