Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.86k stars 529 forks source link

OP_METHSTART, OP_INITFIELD: use shared mem for aux #22083

Closed iabyn closed 2 months ago

iabyn commented 2 months ago

Allocate the aux structure for these two ops using PerlMemShared_malloc() rather then Newx().

OPs (and auxiliary structures) are shared between threads, and there's no guarantee that an OP will be freed by the same thread as the one which created it. Some OSes (Windows IIRC) get upset if memory is malloc()ed and free()d by different threads, since each thread has a separate malloc() pool.

Hence we usually use PerlMemShared_malloc()/_free() to allocate such shared structs. These two recently-added ops were just using Newx().

This commit fixes them.

No tests failures as far as I'm aware - this is more a theoretical thing where one thread compiles some code, creates a child, then exits. The child lives on, and when the child finally exits, the aux struct is freed to the wrong pool.

iabyn commented 2 months ago

Nitpick fixed, and merged.