[erlang-bugs] minor bug in erl_interface.

Fredrik <>
Wed May 8 15:44:24 CEST 2013


On 05/08/2013 12:32 PM, Alexandre Snarskii wrote:
> Hi!
>
> During valgrinding freeswitch compiled with mod_erlang_event
> valgrind output was flooded with messages like the following:
>
> ==96247== Warning: invalid file descriptor -2 in syscall close()
> ==96247==    at 0x7CA9D3: __sys_close (in /usr/lib32/libc.so.7)
> ==96247==    by 0xBC66F3: ei_accept_tmo (in /usr/local/lib/freeswitch/mod/mod_er
> lang_event.so)
> ==96247==    by 0xBBF34F: mod_erlang_event_runtime (mod_erlang_event.c:1957)
> ==96247==    by 0x145DF8: switch_loadable_module_exec (switch_loadable_module.c:
> 98)
> ==96247==    by 0x1F17B3: dummy_worker (thread.c:138)
> ==96247==    by 0x367F19: ??? (in /usr/lib32/libthr.so.3)
>
> According to sources (./lib/erl_interface/src/connect/ei_connect.c), -2 is
> a timeout indication from ei_accept_t:
>
>      if ((fd = ei_accept_t(lfd, (struct sockaddr*)&cli_addr,
>          &cli_addr_len, ms ))<  0) {
>          EI_TRACE_ERR0("ei_accept","<- ACCEPT socket accept failed");
>          erl_errno = (fd == -2) ? ETIMEDOUT : EIO;
>          goto error;
>      }
> [....]
> error:
>      EI_TRACE_ERR0("ei_accept","<- ACCEPT failed");
>      closesocket(fd);
>      return ERL_ERROR;
> } /* ei_accept */
>
> and closesocket on unix systems is defined as just close(2), so any
> timeout or error on accept causes closing invalid file descriptor.
>
> Patch is obvious:
>
>      EI_TRACE_ERR0("ei_accept","<- ACCEPT failed");
> -   closesocket(fd);
> +   if (fd>=0)
> +      closesocket(fd);
>      return ERL_ERROR;
>
Hello Alexandre,
I am making a patch out of this and putting it into testing.
Thanks for noticing and reporting :)

-- 

BR Fredrik Gustafsson
Erlang OTP Team



More information about the erlang-bugs mailing list