[Openmp-commits] [openmp] [OpenMP] Fix td_tdg_task_id underflow when taskloop and taskgraph (PR #150877)

Josep Pinot via Openmp-commits openmp-commits at lists.llvm.org
Tue Sep 30 00:15:11 PDT 2025


jpinot wrote:

> > Right, I missed, that record_map is essentially of type `vector<kmp_node_info_t>`, not `vector<kmp_node_info_t *>`.
> > Another possible approach would be to use a customized vector which allocates `fixed_sized` blocks as necessary (instead of realloc) and redirects `operator[](i)` to look at the `i % fixed_sized` element of block `i / fixed_sized`.
> 
> I have pushed a WIP commit with the changes discussed. However, a data race occurs when thread A reallocates blocks (the array of `blocks`; note that the actual blocks are never resized) to increase the number of blocks, and thread B calls [kmp_node_vector_get](https://github.com/llvm/llvm-project/pull/150877/commits/b151a84f336838f5bdc0f41b1c2798fd2f3fe22e#diff-8402e656316eb873d5db4dea7f697406d15ae4197dcc60d88b3d9fc252fcb69aR5377) to access an existing node. The returned pointer points to invalid data. I suspect this could be due to a compiler optimization or an issue with the return value handling(?).
> 
> @jprotze, do you know what might be causing this?

My bad, the problem was that thread A was holding the freed `old_blocks` pointer in `kmp_node_vector_get` :scream_cat:, I'll clean the changes and push as soon as I re-test everything. 

https://github.com/llvm/llvm-project/pull/150877


More information about the Openmp-commits mailing list