Description
Updated Issue
This is a tracking issue for stabilizing the functionality of Error::type_id
somehow. The subject of a historical security advisory the API was recently changed to prevent memory unsafety issues on all channels including nightly. The functionality, however, is still unstable, so we should stabilize it at some point!
Original issue.
Reported by @seanmonstar to the security mailing list recently, it was discovered that the recent stabilization of Error::type_id
in Rust 1.34.0 is actually not memory safe. Described in a recent security announcement the stabilization of Error::type_id
has been reverted for stable, beta, and master.
This leaves us, however, with the question of what to do about this API? Error::type_id
has been present since the inception of the Error
trait, all the way back to 1.0.0. It's unstable, however, and is pretty rare as well to have a manual implementation of the type_id
function. Despite this we would ideally still like a path to stability which includes safety at some point.
This tracking issue is intended to serve as a location to discuss this issue and determine the best way forward to fully removing Error::type_id
(so even nightly users are not affected by this memory safety issue) and having a stable mechanism for the functionality.
Activity
Destabilize the `Error::type_id` function
Destabilize the `Error::type_id` function
Destabilize the `Error::type_id` function
Error::type_id
function #60785Error::type_id
function #60786Error::type_id
function #60787Centril commentedon May 13, 2019
Here's an unbaked thought: Can we make an extension
unsafe trait ErrorTypeIdExt
toError
, seal that extension trait (meaning that users cannot implement it), and then provide a blanket implementation forError
?crlf0710 commentedon May 13, 2019
I think my unbaked idea is not implementable in current Rust:
The only problem is we can't add a "where Self:Sized" bound to the "{ self as _ }" part.
SimonSapin commentedon May 13, 2019
It’s tempting to make
Any
a super-trait ofError
, and rely onAny::type_id
. This would be sound becauseAny
already has a blanket impl that covers every possible impl, so it cannot be overridden.However
Any
requires'static
butError
doesn’t (only itsTypeId
-related methods do), so this plan doesn’t work as-is.skade commentedon May 13, 2019
@SimonSapin Wasn't relating Any's bound discussed at some point?
scottmcm commentedon May 13, 2019
On unstable we have
#[marker]
traits which cannot override anything in their impls -- if they were allowed to define associated items with defaults in their trait definition, it would be another way to do this, though that considered too large a change to make with just a PR in #53693 (comment).51 remaining items