Re: [PATCH] Allocate cpg_dispatch message buffer in heap instead of stack

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 4/17/2013 3:52 PM, José Orlando Pereira wrote:
> The large stack size in cpg_dispatch, resulting from the
> message buffer, is causing a segmentation fault in environments
> with a constrained stack size, namely, when calling into
> cpg_dispatch from Java using JNI (i.e. for
> http://github.com/jopereira/jgcs/tree/master/jgcs-corosync).
> ---
>  lib/cpg.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/cpg.c b/lib/cpg.c
> index b96df4e..f3b2bff 100644
> --- a/lib/cpg.c
> +++ b/lib/cpg.c
> @@ -346,7 +346,7 @@ cs_error_t cpg_dispatch (
>  	struct cpg_ring_id ring_id;
>  	uint32_t totem_member_list[CPG_MEMBERS_MAX];
>  	int32_t errno_res;
> -	char dispatch_buf[IPC_DISPATCH_SIZE];
> +	char* dispatch_buf;

style: char *dispatch_buf = NULL;

>  
>  	error = hdb_error_to_cs (hdb_handle_get (&cpg_handle_t_db, handle, (void *)&cpg_inst));
>  	if (error != CS_OK) {
> @@ -361,6 +361,7 @@ cs_error_t cpg_dispatch (
>  		timeout = 0;
>  	}
>  
> +	dispatch_buf = malloc(IPC_DISPATCH_SIZE);

if (dispatch_buf == NULL) {
    .... return appropriate error ....
}


>  	dispatch_data = (struct qb_ipc_response_header *)dispatch_buf;
>  	do {
>  		errno_res = qb_ipcc_event_recv (
> @@ -504,6 +505,7 @@ cs_error_t cpg_dispatch (
>  
>  error_put:
>  	hdb_handle_put (&cpg_handle_t_db, handle);
> +	free(dispatch_buf);
>  	return (error);
>  }

and you will need to repeat this patch for all libraries.

Fabio

_______________________________________________
discuss mailing list
discuss@xxxxxxxxxxxx
http://lists.corosync.org/mailman/listinfo/discuss





[Index of Archives]     [Linux Clusters]     [Corosync Project]     [Linux USB Devel]     [Linux Audio Users]     [Photo]     [Yosemite News]    [Yosemite Photos]    [Linux Kernel]     [Linux SCSI]     [X.Org]

  Powered by Linux