[committed] libgomp: Fix up OMP_PROC_BIND handling [PR106894]

Message ID YxsognvVm2JUJuQ8@tucnak
State New, archived
Headers
Series [committed] libgomp: Fix up OMP_PROC_BIND handling [PR106894] |

Commit Message

Jakub Jelinek Sept. 9, 2022, 11:50 a.m. UTC
  On Wed, Aug 31, 2022 at 12:56:25PM +0200, Marcel Vollweiler wrote:
> +	  case PARSE_BIND:
> +	    *(char *) (host_envvars[omp_var].dest[0])
> +		  = *(char *) params[0];
> +	    *(char *) (host_envvars[omp_var].dest[1])
> +		  = *(char *) params[1];
> +	    *(unsigned long *) (host_envvars[omp_var].dest[2])
> +		  = *(unsigned long *) params[2];

While the first param is char (gomp_global_icv.bind_var), the second param
is char * (gomp_bind_var_list), so we shouldn't access it through *(char *).

Tested on x86_64-linux with
make check RUNTESTFLAGS="c.exp='*affinity* icv-6.c *display*' c++.exp='*affinity* icv-6.c *display*' fortran.exp='*affinity*'"
which previously had various failures, committed to trunk.

2022-09-09  Jakub Jelinek  <jakub@redhat.com>

	PR libgomp/106894
	* env.c (initialize_env) <case PARSE_BIND>: Use char ** instead of
	char * for dest[1] initialization from params[1].  Formatting fixes.



	Jakub
  

Patch

--- libgomp/env.c.jj	2022-09-08 20:22:07.849183684 +0200
+++ libgomp/env.c	2022-09-09 13:30:14.090107492 +0200
@@ -2184,12 +2184,10 @@  initialize_env (void)
 	    *(int *) (host_envvars[omp_var].dest[1]) = *(int *) params[1];
 	    break;
 	  case PARSE_BIND:
-	    *(char *) (host_envvars[omp_var].dest[0])
-		  = *(char *) params[0];
-	    *(char *) (host_envvars[omp_var].dest[1])
-		  = *(char *) params[1];
+	    *(char *) (host_envvars[omp_var].dest[0]) = *(char *) params[0];
+	    *(char **) (host_envvars[omp_var].dest[1]) = *(char **) params[1];
 	    *(unsigned long *) (host_envvars[omp_var].dest[2])
-		  = *(unsigned long *) params[2];
+	      = *(unsigned long *) params[2];
 	    break;
 	  }
       }