[ 
https://issues.apache.org/jira/browse/DISPATCH-1685?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17129666#comment-17129666
 ] 

ASF GitHub Bot commented on DISPATCH-1685:
------------------------------------------

kgiusti commented on a change in pull request #757:
URL: https://github.com/apache/qpid-dispatch/pull/757#discussion_r437615900



##########
File path: include/qpid/dispatch/ctools.h
##########
@@ -217,4 +218,41 @@ do {                                    \
 #define MIN(a,b) (((a)<(b))?(a):(b))
 #define MAX(a,b) (((a)>(b))?(a):(b))
 
+//
+// Heap allocation with abort() on failure
+//
+
+static inline void *qd_malloc(size_t size)
+{
+    void *ptr = malloc(size);
+    if (!ptr)
+        abort();

Review comment:
       I was thinking about that, but decided that if a hard memory limit is 
hit it is unlikely that doing any I/O would succeed.
   
   But at this point it probably cannot hurt to call perror before aborting...  
at best it will indicate the failure was due to low memory.   I'll update the 
patch.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


> Provide heap memory allocation wrappers that call abort() on failure to 
> allocate
> --------------------------------------------------------------------------------
>
>                 Key: DISPATCH-1685
>                 URL: https://issues.apache.org/jira/browse/DISPATCH-1685
>             Project: Qpid Dispatch
>          Issue Type: New Feature
>            Reporter: Ken Giusti
>            Assignee: Ken Giusti
>            Priority: Major
>
> The dispatch router allocates heap memory using the malloc API.  In many 
> cases should a call to malloc fail to return the requested memory the router 
> cannot recover.  In fact there are many places in the code where the return 
> value from a heap allocation call is not even checked for NULL.
> This feature would provide a set of wrapper functions for all heap allocation 
> operations used by the router.  These wrapper functions will unconditionally 
> invoke abort() on heap allocation failure.  Note that these are not 
> conditionally compiled out when NDEBUG is defined - abort() is called 
> regardless of build type.
> The intent is to use these wrapper functions wherever a heap allocation 
> failure is not recoverable.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to