hawq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zhangh43 <...@git.apache.org>
Subject [GitHub] incubator-hawq pull request: HAWQ-141. memory accessing panic in s...
Date Tue, 10 Nov 2015 06:16:24 GMT
Github user zhangh43 commented on a diff in the pull request:

    https://github.com/apache/incubator-hawq/pull/90#discussion_r44373290
  
    --- Diff: src/backend/resourcemanager/communication/rmcomm_QD2RM.c ---
    @@ -234,12 +245,59 @@ void initializeQD2RMComm(void)
         /* Start resource heart-beat thread. */
         if ( rm_session_lease_heartbeat_enable )
         {
    +    	/* Resolve resource manager server address here before creating thread. */
    +    	struct hostent *rmserver = gethostbyname(master_addr_host);
    +    	if ( rmserver == NULL )
    +    	{
    +    		elog(ERROR, "failed to resolve resource manager hostname %s. herror %s",
    +    					master_addr_host,
    +						hstrerror(h_errno));
    +    	}
    +
    +    	HeartBeatThreadArg tharg = malloc(sizeof(HeartBeatThreadArgData));
    +    	tharg->HostAddrLength = rmserver->h_length;
    +    	tharg->HostAddrs      = NULL;
    +    	tharg->HostAddrSize   = 0;
    +
    +    	/* Get total and INET address count. */
    +    	int addrcnt = 0;
    +    	while( rmserver->h_addr_list[addrcnt] != NULL )
    +    	{
    +    		addrcnt++;
    +    		if ( rmserver->h_addrtype == AF_INET )
    +    		{
    +    			tharg->HostAddrSize++;
    +    		}
    +    	}
    +    	elog(DEBUG3, "Resolved resource manager host %s to %d INET addresses.",
    +    				 master_addr_host,
    +					 tharg->HostAddrSize);
    +
    +    	tharg->HostAddrs = malloc(sizeof(char *) * tharg->HostAddrSize);
    --- End diff --
    
    I think in line 1433 you also need to free (*arg)->HostAddrs.
    but also pay attention to line 276: if h_addrtype != AF_INET then tharg->HostAddrSize
=0, which leads to  malloc(0) happens.  In this case, you should not free (*arg)->HostAddrs



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message