On 9/20/11 4:24 PM, Kieran Mansley wrote:
On Mon, 2011-09-19 at 10:31 +0300, Matias Mandell wrote:

In the end of event_callback() when it has gone thru all tasks waiting
for a select() it unprotects&protects and starts over from the
beginning. At this point the sock->select_waiting was sometimes zero and
the loop crashed.


In lwip_select() there are protections when adding/removing from list
and increasing/decreasing sock->select_waiting counters but they are not
in sync. How good idea is it to pass a local variable to another task,
there might be context switching in between? I might have a stack
overflow or something going on...
Without looking at the code I'm not quite sure what the problem is.  Do
you have a patch to fix it as that would show clearly what you're
describing.

In short, the lwip_select()-function's local variable
    struct lwip_select_cb select_cb;
is also used within the event_callback()-function.

I do not get a crash if I:
- exit the event_callback()-loop upon "sock->select_waiting==0", see attached excerpt.
or
- create static memory for the select_cb:s.


There is not a stack overflow, but I'm not sure how the stack is saved/loaded upon context switching. I am also experiencing problems opening new sockets after closing old ones, I have not looked at it but there seems to be another email discussion about it.


Sincerely, Matias

--
mat!as

    /* unlock interrupts with each step */
    last_select_cb_ctr = select_cb_ctr;
    SYS_ARCH_UNPROTECT(lev);
    /* this makes sure interrupt protection time is short */
    SYS_ARCH_PROTECT(lev);

        if (sock->select_waiting == 0) {
                /* noone is waiting for this socket, no need to check 
select_cb_list */
                SYS_ARCH_UNPROTECT(lev);
                return;
        }

    if (last_select_cb_ctr != select_cb_ctr) {
      /* someone has changed select_cb_list, restart at the beginning */
      goto again;
    }
_______________________________________________
lwip-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to