EW-9753 Enable deprecation warnings for attaching to refcounted objects#5513
EW-9753 Enable deprecation warnings for attaching to refcounted objects#5513
Conversation
|
2f230de to
8af2aab
Compare
|
Maybe not as common, but does this miss |
No, that should already be covered – RefcountedWrapper inherits from kj::Refcounted and does not define any attach methods on its own. |
RefcountedWrapper does, but the underlying type is what's checked. |
Maybe I'm missing something, but I think it works just fine: |
|
|
That function call would not result in a deprecation warning but I think that's just fine, that would not leave us vulnerable to attachment lifetime being shorter than expected: The lifetime of the attachment is tied to when the wrapped variable is deallocated which is only when all instances of the RefcountedWrapper have been deallocated, so the lifetime does not depend on that of a single instance of the wrapper. |
No. The attachment is tied to the |
|
It's unclear that there's a legitimate use case for It ends up being "this was the easy way to make it compile" |
Here's two use cases where we'd have to come up with a replacement for attachToThisReference():
If we want to not use attachToThisReference(), we'll need an alternative approach for both of these use cases. |
@jasnell could you strategically advise here? We're not fully locking down this bad pattern by allowing |
|
I haven't read the full PR and don't have complete context. What are the expected semantics of In general, I've never really liked how |
It bypasses the protection from attaching to refcounted objects added here. @kentonv raised the concern behind this change.
How should we go about this? |
I don't believe there's a way to do it systematically. It would have to be on a case by case basis, with each individual type. Essentially, all I mean by the comment is that I rather wish we'd get away from attachments on the smart-pointers and instead rely on attachments on the actual objects, which is more of a general style change. |
mar-cf
left a comment
There was a problem hiding this comment.
Unresolved questions on the validity of the approach
If you're not convinced that this approach is valid, can you suggest an alternative approach? |
|
I think for the sake of making progress, an incremental approach should be fine. Absent a concrete alternative now, we can go with |
|
The concrete alternative I prefer to see is to remove |
|
Yeah, I get that. However, for the couple of places it's used, are you certain the lifecycles of the objects will allow for that? If not, the "concrete suggestions" I would prefer to see would be the changes that ensure the lifecycle is correct, if any are needed. |
|
I agree with James here – in some cases it's hard to avoid. Mar, did you consider the two use cases for attachToThisReference() I described above? |
My suspicion is they're all possible to rework. I pulled you in to confirm my intuition, and I will lift my objection if you feel it's unavoidable. To me, doesn't seem so.
Is the first concern theoretical or real case somewhere? That seems like a case on unintentional inheritance. |
|
It's likely possible to rework. I think the more important question is whether it's necessary to block this to wait on that. Some effort to determine what reworking those would look like and the extent of the changes would be needed. I'd say it's likely good to pursue as a follow up. |
8af2aab to
1746bf0
Compare
SG. Given that we've already found one bug, we should evaluate each use of |
Commenting didn't seem to lift changes requested
0e52e71 to
446230c
Compare
446230c to
d986285
Compare
- This includes making TailStreamWriter non-refcounted.
d986285 to
6840b5f
Compare
No description provided.