Closed Bug 1626149 Opened 5 years ago Closed 5 years ago

Use PlainOldDataSerializer again for some types

Categories

(Core :: IPC, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: emk, Unassigned)

References

Details

Bug 1620400 had to stop using PlainOldDataSerializer for some types because Maybe was not trivially copyable.

But bug 1613363 made Maybe<trivially copyable type> trivially copyable. So we can use PlainOldDataSerializer again now.

Blocks: 1622344
No longer blocks: 1620400
Component: MFBT → IPC

Ah, is_trivially_copyable != is_trivially_copy_constructible. PlainOldDataSerializer requires the prior.

Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → INVALID

PlainOldDataSerializer checks for is_trivially_copyable, but I think is_trivially_destructible plus is_trivially_copy_constructible (and maybe is_trivially_copy_assignable) is sufficient for its purposes, so maybe the check should be relaxed. The reason Maybe<trivially copyable type> is not trivially copyable itself is that its move operations are not trivial, to guarantee a moved-from Maybe is always empty/nothing. (Though I am not sure if this guarantee really should be given, I didn't implement it like that in order to preserve the existing behaviour)

Flags: needinfo?(kats)

No, is_trivially_copy_constructible is not sufficient. The C++ spec requires is_trivially_copyable.

I don't have any opinion here, will defer to the more knowledgeable C++ hackers.

Flags: needinfo?(kats)
See Also: → 1626528

Why I can't access bug 1620719 (7935cf13d83f) and bug 1613009 (ead2e7c7696c and e798886970d1)? I thought that they are security sensitive.

Flags: needinfo?(kats)

(In reply to Masatoshi Kimura [:emk] from comment #5)

Why I can't access bug 1620719 (7935cf13d83f) and bug 1613009 (ead2e7c7696c and e798886970d1)? I thought that they are security sensitive.

Yep. I cc'ed you on them.

Flags: needinfo?(kats)

A few thoughts here:

  • C++ does indeed require is_trivially_copyable to copy the bytes of an object around. The requirement is stated here.
  • It's not clear to me why this stricter requirement is in place. The more relaxed requirement Simon suggests in comment 2 seems sensible to me.
  • std::optional<T> made the design choice that if you move from a populated optional, the moved-from optional remains populated (with its contained object in a moved-from state) rather than empty. As a result, std::optional<T> can be implemented in a way that it is trivially copyable if T is.
You need to log in before you can comment on or make changes to this bug.