#607 out of memory breaks server_select

Reporter Daurnimator
Owner Nobody
Created
Updated
Stars ★ (1)  
Tags
  • Priority-Medium
  • Type-Defect
  • Status-Accepted
  1. Daurnimator on

    This traceback occured thousands of times *after* an OOM error: ``` general: Top-level error, please report: /usr/lib/prosody/net/server_select.lua:507: invalid value (nil) at index 1 in table for 'concat' general: stack traceback: [C]: in function 'table_concat' /usr/lib/prosody/net/server_select.lua:507: in function 'sendbuffer' /usr/lib/prosody/net/server_select.lua:893: in function </usr/lib/prosody/net/server_select.lua:877> [C]: in function 'xpcall' /usr/bin/prosody:374: in function 'loop' /usr/bin/prosody:405: in main chunk [C]: at 0x00404c20 ``` This error couldn't happen via that code path of `socket:write(nil)`, as the length operator invoked on the argument would throw before this point. (`bufferlen = bufferlen + #data`) Another suspect place for a `nil` to slip in is: ``` for i = bufferqueuelen,1,-1 do bufferqueue[ i ] = nil end ``` If there was an error before `bufferqueuelen` was reset, in the subsequent if/else chain then it might be out of sync.

  2. Zash on

    How about this? diff -r d17bccb19143 net/server_select.lua --- a/net/server_select.lua Tue Feb 21 18:54:44 2017 +0100 +++ b/net/server_select.lua Sat Feb 25 02:21:44 2017 +0100 @@ -856,7 +856,10 @@ loop = function(once) -- this is the mai for i, socket in ipairs( write ) do -- send data waiting in writequeues local handler = _socketlist[ socket ] if handler then - handler.sendbuffer( ) + local ok, err = pcall( handler.sendbuffer ) + if not ok then + _closelist[ handler ] = err; + end else closesocket( socket ) out_put "server.lua: found no handler and closed socket (writelist)" -- this should not happen @@ -865,7 +868,10 @@ loop = function(once) -- this is the mai for i, socket in ipairs( read ) do -- receive data local handler = _socketlist[ socket ] if handler then - handler.readbuffer( ) + local ok, err = pcall( handler.readbuffer ) + if not ok then + _closelist[ handler ] = err; + end else closesocket( socket ) out_put "server.lua: found no handler and closed socket (readlist)" -- this can happen

    Changes
    • title server_select.lua:507: invalid value (nil) at index 1 in table for 'concat' out of memory breaks server_select

New comment