Skip to content

Extend the enum check to pointer and union reads #144353

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

1c3t3a
Copy link
Member

@1c3t3a 1c3t3a commented Jul 23, 2025

This change extends the previously added enum discriminant check to enums read through a union or pointer. At the moment we only insert the check when transmuting to an enum. Although I hoped for it, this check isn't yet inserted for calls to MaybeUninit::assume_init, because the pass is running on polymorphic MIR and thus doesn't have the information yet to know whether the type that is read is an enum.

r? @saethlin

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 23, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 23, 2025

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jul 23, 2025
@rust-log-analyzer

This comment has been minimized.

@1c3t3a 1c3t3a force-pushed the enum-check-enum-ptr branch from ccd9d59 to ec30c0d Compare July 23, 2025 13:21
@rust-log-analyzer

This comment has been minimized.

@1c3t3a

This comment was marked as outdated.

@1c3t3a 1c3t3a force-pushed the enum-check-enum-ptr branch from ec30c0d to 852275f Compare July 24, 2025 08:34
@rust-log-analyzer

This comment has been minimized.

@1c3t3a 1c3t3a force-pushed the enum-check-enum-ptr branch from 852275f to aeaa360 Compare July 24, 2025 13:18
@rust-log-analyzer

This comment has been minimized.

This change extends the previously added enum discriminant check to
enums read through a union or pointer. At the moment we only insert
the check when transmuting to an enum. Although I hoped for it, this
check isn't yet inserted for calls to `MaybeUninit::assume_init`,
because the pass is running on polymorphic MIR and thus doesn't have
the information yet to know whether the type that is read is an
enum.
@1c3t3a 1c3t3a force-pushed the enum-check-enum-ptr branch from aeaa360 to 34076b4 Compare July 24, 2025 14:21
@rust-log-analyzer
Copy link
Collaborator

The job aarch64-gnu-llvm-19-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
NOTE: compiletest thinks it is using GDB version 15001000

error: gdb failed to execute
status: exit status: 1
command: PYTHONPATH="/checkout/src/etc" "/usr/bin/gdb" "-quiet" "-batch" "-nx" "-command=/checkout/obj/build/aarch64-unknown-linux-gnu/test/debuginfo/type-names.gdb/type-names.debugger.script"
--- stdout -------------------------------
GNU gdb (Ubuntu 15.1-1ubuntu2) 15.1
Copyright (C) 2024 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "aarch64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word".
Breakpoint 1 at 0x3280: file /checkout/tests/debuginfo/type-names.rs, line 473.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/aarch64-linux-gnu/libthread_db.so.1".

Program received signal SIGABRT, Aborted.
0x0000fffff7ca6898 in ?? () from /lib/aarch64-linux-gnu/libc.so.6
------------------------------------------
--- stderr -------------------------------

thread 'main' panicked at /checkout/tests/debuginfo/type-names.rs:414:62:
null pointer dereference occurred

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants