Yuxuan Chen
8db94f8248
[clang][Modules] Keep existing global definition on type mismatch in GetOrCreateLLVMGlobal ( #223877 )
...
When a global is requested for definition but a definition with the same
mangled name already exists, return it as is instead of creating a fresh
global and erasing the defined one, even if its type differs from the
requested type.
The type can legitimately differ when the initializer folded to a
different (e.g. anonymous) type, as happens with unions. Erasing the
defined global dangles pointers held by callers, e.g. the
`AssociatedData` of entries in `llvm.global_ctors`, leading to a
use-after-free crash during `EmitCtorList`. This also keeps the
deferred-decls "already emitted" check sound, since it queries with
`IsForDefinition`, which must be non-destructive.
Add a header-unit regression test: an inline variable with an
anonymous-union member, constant-initialized but requiring dynamic
destructor registration, must be emitted exactly once when imported from
header units. The folded initializer has an anonymous type that differs
from the declared type; a second emission used to replace (and erase)
the already-defined global, leaving a dangling pointer in
`llvm.global_ctors` (use-after-free, observable as a crash under ASan).
Assisted-By: Meta Muse 1.3
Co-authored-by: Michael Park <mcypark@gmail.com >
(cherry picked from commit 2a6fdac960de3a6bae854474f12e8f1edfcd9a04)
2026-11-02 10:44:26 +00:00
..
2026-06-05 22:34:02 +02:00
2026-06-05 12:36:55 +02:00
2026-04-12 17:38:57 +02:00
2026-03-06 08:33:34 +00:00
2026-06-09 11:46:44 -07:00
2026-06-24 11:36:29 +01:00
2026-05-25 22:13:43 -07:00
2026-07-02 09:35:24 -07:00
2026-06-24 11:36:29 +01:00
2026-04-28 11:09:13 +01:00
2026-07-02 09:35:24 -07:00
2026-07-02 09:35:24 -07:00
2026-05-29 14:09:06 +08:00
2026-05-29 14:09:06 +08:00
2026-06-05 22:34:02 +02:00
2026-07-02 09:35:24 -07:00
2026-07-02 09:35:24 -07:00
2026-05-29 14:09:06 +08:00
2026-05-29 14:09:06 +08:00
2026-06-30 08:39:54 +00:00
2026-06-30 08:39:54 +00:00
2026-06-30 08:39:54 +00:00
2026-03-04 16:13:48 -06:00
2026-03-06 08:33:34 +00:00
2026-07-02 09:35:24 -07:00
2026-03-06 08:33:34 +00:00
2026-03-04 16:13:48 -06:00
2026-05-07 13:16:14 -04:00
2026-05-21 22:16:40 +08:00
2026-06-05 12:36:55 +02:00
2026-05-07 13:16:14 -04:00
2026-07-02 09:35:24 -07:00
2026-04-18 01:50:39 +00:00
2026-03-20 20:30:53 -03:00
2026-05-26 07:20:14 +00:00
2026-04-27 17:07:20 -04:00
2026-07-02 09:35:24 -07:00
2026-03-06 08:33:34 +00:00
2026-04-27 17:07:20 -04:00
2026-03-06 08:33:34 +00:00
2026-05-29 14:09:06 +08:00
2026-03-27 09:58:59 -07:00
2026-07-07 16:04:23 -07:00
2026-06-09 20:26:48 -07:00
2026-06-25 15:29:21 +02:00
2026-04-12 17:38:57 +02:00
2026-05-07 13:16:14 -04:00
2026-07-09 11:06:31 -07:00
2026-07-02 09:35:24 -07:00
2026-05-29 14:09:06 +08:00
2026-03-06 08:33:34 +00:00
2026-05-28 10:18:27 +02:00
2026-03-06 08:33:34 +00:00
2026-07-02 09:35:24 -07:00
2026-05-21 22:16:40 +08:00
2026-03-06 08:33:34 +00:00
2026-03-06 08:33:34 +00:00
2026-07-10 16:13:55 -07:00
2026-07-11 00:01:08 +02:00
2026-07-11 00:01:08 +02:00
2026-07-11 00:01:08 +02:00
2026-07-11 00:01:08 +02:00
2026-07-11 00:01:08 +02:00
2026-07-11 00:01:08 +02:00
2026-03-06 08:33:34 +00:00
2026-05-07 13:16:14 -04:00
2026-05-29 14:09:06 +08:00
2026-06-16 18:19:03 -04:00
2026-04-01 19:25:43 +00:00
2026-07-09 12:11:45 +00:00
2026-07-09 12:58:50 -06:00
2026-07-02 09:35:24 -07:00
2026-03-30 16:34:37 -07:00
2026-07-15 10:07:19 +00:00
2026-09-05 09:11:54 +02:00
2026-07-02 09:35:57 +02:00
2026-03-20 15:51:28 +01:00
2026-05-29 14:09:06 +08:00
2026-05-29 14:09:06 +08:00
2026-06-05 22:34:02 +02:00
2026-05-29 14:09:06 +08:00
2026-07-08 13:36:43 +02:00
2026-06-25 19:15:49 -07:00
2026-07-09 09:12:47 -07:00
2026-07-09 09:12:47 -07:00
2026-07-02 09:35:24 -07:00
2026-04-30 00:43:04 +08:00
2026-04-27 17:07:20 -04:00
2026-07-09 12:11:45 +00:00
2026-04-02 14:01:45 +02:00
2026-07-02 09:35:24 -07:00
2026-03-06 08:33:34 +00:00
2026-05-07 13:16:14 -04:00
2026-05-07 13:16:14 -04:00
2026-03-04 16:13:48 -06:00
2026-03-06 08:33:34 +00:00
2026-03-06 08:33:34 +00:00
2026-03-06 08:33:34 +00:00
2026-07-06 11:57:38 +02:00
2026-11-02 10:44:26 +00:00
2026-07-02 09:35:24 -07:00
2026-05-07 13:16:14 -04:00
2026-04-27 17:07:20 -04:00
2026-07-02 09:35:24 -07:00
2026-07-02 09:35:24 -07:00
2026-07-02 09:35:24 -07:00
2026-07-02 09:35:24 -07:00
2026-06-05 12:36:55 +02:00
2026-05-29 14:09:06 +08:00
2026-07-09 11:06:31 -07:00
2026-03-06 08:33:34 +00:00
2026-05-07 13:16:14 -04:00
2026-05-03 18:13:29 +02:00
2026-04-27 17:07:20 -04:00
2026-06-30 08:39:54 +00:00
2026-05-15 16:50:30 +02:00
2026-07-08 13:36:43 +02:00
2026-07-08 13:36:43 +02:00
2026-02-28 03:18:11 +08:00
2026-07-06 14:52:11 -07:00
2026-03-27 09:58:59 -07:00
2026-06-24 11:36:29 +01:00
2026-04-27 13:46:42 -03:00
2026-07-09 11:06:31 -07:00
2026-05-29 14:09:06 +08:00
2026-07-02 09:35:24 -07:00
2026-07-02 09:35:24 -07:00
2026-07-02 09:35:24 -07:00
2026-03-10 16:04:24 -04:00
2026-03-10 16:04:24 -04:00
2026-05-29 14:09:06 +08:00
2026-07-02 09:35:24 -07:00
2026-07-02 09:35:24 -07:00
2026-07-10 16:13:55 -07:00
2026-07-02 09:35:57 +02:00
2026-07-02 09:35:24 -07:00
2026-06-05 22:34:02 +02:00
2026-06-05 22:34:02 +02:00
2026-06-05 22:34:02 +02:00
2026-06-05 22:34:02 +02:00
2026-05-29 14:09:06 +08:00
2026-05-29 14:09:06 +08:00
2026-07-22 13:45:45 +00:00
2026-03-17 11:06:38 +01:00
2026-07-22 13:45:45 +00:00
2026-05-29 14:09:06 +08:00
2026-07-29 08:57:11 +02:00
2026-03-06 08:33:34 +00:00
2026-05-29 14:09:06 +08:00
2026-07-10 19:17:57 +00:00
2026-07-02 09:35:24 -07:00
2026-05-29 14:09:06 +08:00
2026-03-30 16:34:37 -07:00
2026-07-22 13:45:45 +00:00
2026-08-23 19:11:41 +00:00
2026-07-22 13:45:45 +00:00
2026-07-22 13:45:45 +00:00
2026-07-22 13:45:45 +00:00
2026-07-10 16:13:55 -07:00
2026-04-08 23:06:49 +02:00
2026-04-08 23:06:49 +02:00
2026-05-29 09:03:09 +00:00
2026-04-23 23:31:27 -05:00
2026-03-06 08:33:34 +00:00
2026-05-22 21:55:41 -07:00
2026-06-25 15:29:21 +02:00
2026-06-17 09:16:17 +00:00
2026-07-02 09:35:24 -07:00
2026-05-29 09:03:09 +00:00
2026-07-02 09:35:24 -07:00
2026-04-03 15:28:34 -07:00
2026-03-03 04:54:46 +01:00
2026-07-13 19:07:24 +00:00
2026-07-02 09:35:24 -07:00
2026-05-29 14:09:06 +08:00
2026-05-29 14:09:06 +08:00
2026-03-25 09:12:21 -07:00
2026-05-29 14:09:06 +08:00
2026-06-05 22:34:02 +02:00
2026-05-29 14:09:06 +08:00
2026-06-05 22:34:02 +02:00
2026-07-09 09:12:47 -07:00
2026-07-09 11:06:31 -07:00
2026-06-05 22:34:02 +02:00
2026-05-29 14:09:06 +08:00
2026-07-02 09:35:24 -07:00
2026-05-29 14:09:06 +08:00
2026-05-29 14:09:06 +08:00
2026-07-09 11:06:31 -07:00
2026-03-27 12:07:23 +08:00
2026-03-27 12:07:23 +08:00
2026-03-28 05:22:55 +01:00
2026-07-02 09:35:24 -07:00
2026-07-02 09:35:24 -07:00
2026-07-02 09:35:24 -07:00
2026-05-04 14:08:11 +08:00
2026-07-06 16:40:31 -07:00
2026-03-28 05:22:55 +01:00
2026-06-30 08:39:54 +00:00
2026-07-07 11:16:56 -04:00
2026-04-29 08:43:02 +02:00
2026-07-09 11:06:31 -07:00
2026-07-02 09:35:24 -07:00
2026-07-02 09:35:24 -07:00
2026-07-09 11:06:31 -07:00
2026-05-29 14:09:06 +08:00
2026-07-14 00:06:26 +08:00
2026-04-27 12:30:03 +02:00
2026-05-15 01:29:57 +00:00
2026-03-06 08:33:34 +00:00
2026-07-02 09:35:24 -07:00
2026-05-29 14:09:06 +08:00
2026-07-09 11:06:31 -07:00
2026-05-29 14:09:06 +08:00
2026-07-09 11:06:31 -07:00
2026-03-06 14:39:37 +01:00
2026-05-29 14:09:06 +08:00
2026-05-29 14:09:06 +08:00
2026-05-29 14:09:06 +08:00
2026-07-09 11:06:31 -07:00
2026-07-09 11:06:31 -07:00
2026-05-29 14:09:06 +08:00
2026-05-29 14:09:06 +08:00
2026-05-29 14:09:06 +08:00
2026-05-29 14:09:06 +08:00
2026-05-29 14:09:06 +08:00
2026-07-09 11:06:31 -07:00
2026-05-29 14:09:06 +08:00
2026-07-09 11:06:31 -07:00
2026-05-29 14:09:06 +08:00
2026-05-29 14:09:06 +08:00
2026-03-06 08:33:34 +00:00
2026-05-29 14:09:06 +08:00
2026-07-09 11:06:31 -07:00
2026-07-02 09:35:24 -07:00
2026-09-05 09:11:47 +02:00
2026-06-24 22:07:33 -07:00
2026-05-29 14:09:06 +08:00
2026-07-02 09:35:24 -07:00
2026-07-02 09:35:24 -07:00