CORE DUMP WITH CALLOC

ITEM: RTA000053364



                                                                                
                                                                                
                                                                                
Source: QUAT-AB item 089520                                                     
Question:                                                                       
    My customer has an application that implements a videotext                  
system in a RISC System/6000 7011-230 with 64MB of memory,                      
152MB of paging space and 128 asynch ports running AIX 3.2.5.                   
                                                                                
   Every so often one of the main processes (a process called pavtel_b.x        
which is the process that controls the videotext terminals) stops               
abruptly and dumps a core file.                                                 
Inspecting the core file the customer has noticed that the program              
stopped when trying to execute a "calloc" call.                                 
Doing some additional analysis, the customer noticed that                      
under some conditions the number of callocs can exceed the                      
number of frees, causing the process to consume a considerable                  
amount of memory.                                                               
                                                                                
  The question that arises is that if there was not                             
enough virtual memory to fulfill the request, the calloc call should            
have returned an error and not have the process die abruptly and                
generated a core dump, correct ?                                                
====> RECV: QUIPNEW  AT TOROHON1 ======================== DATE:941215 TIME:123  
Question 015739 received 14 Dec 1994 at 13:27:30 as QUAT item 089490            
                                                                                
---------- ---------- ---------- --------- ---------- ----------                
A: Unfortunately, the 'calloc' subroutine is working as designed.  If           
   paging space reaches a certain threshhold, processes will be killed.         
   However, before this threshhold is reached, a SIGDANGER signal is           
   sent to the high users of paging space.  This signal can be trapped          
   and your application can respond accordingly.                                
                                                                                
   There is sample source code in '/usr/lpp/bos/samples'.  The file is          
   'psmalloc.c'.  This code essentially mallocs space, touches the space        
   one page at a time, and traps on the SIGDANGER signal.  If the code          
   detects a SIGDANGER, it aborts the malloc and disclaims the space,           
   preventing the 'SIGKILL' signal from being sent to the application.          
                                                                                
   Another option is to set ulimits to a particular value for the user          
   running the application.  With the data segment limit set, calloc            
   will return a null pointer with errno set to ENOMEM when a request is        
   made to allocate space beyond that allowed by the user's limits.             
                                                                                
   Additional information can be found in InfoExplorer under the 'calloc'      
  and 'ulimit' articles.  We also have sample source code implementing          
  the SIGDANGER trap we could fax you if you are interested.  If you have       
  further questions, feel free to reopen this item.                             
                                                                                
---------- ---------- ---------- --------- ---------- ----------                
                                                                                
                                                                                
This item was created from library item Q677083      I0916                      
                                                                                
Additional search words:                                                        
CALLOC CORE DUMP DUMPING IX I0916 JAN95 LPPS MAIN MEMORY OZNEW RISCO            
RISCSYSTEM SOFTWARE STORAGE SUPT                                                
                                                                                
                                                                                
                                                                               


WWQA: ITEM: RTA000053364 ITEM: RTA000053364
Dated: 01/1995 Category: RISCO
This HTML file was generated 99/06/24~12:43:21
Comments or suggestions? Contact us