Bug 224480 - Remove the comment in ~AudioSourceProviderAVFObjC about undefined behavior
Summary: Remove the comment in ~AudioSourceProviderAVFObjC about undefined behavior
Status: ASSIGNED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Kimmo Kinnunen
URL:
Keywords: InRadar
Depends on: 224230
Blocks:
  Show dependency treegraph
 
Reported: 2021-04-13 05:12 PDT by Kimmo Kinnunen
Modified: 2021-04-20 05:13 PDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kimmo Kinnunen 2021-04-13 05:12:45 PDT
AudioSourceProviderAVFObjC locks a mutex in destructor.
This is undefined behavior, since the mutex controls access to the object members.
Since the object cannot have multiple active references during destruction, mutex locking should not be needed.
However, it is needed, and as such this indicates undefined behavior.ยด
Comment 1 Alexey Proskuryakov 2021-04-13 15:01:25 PDT
> This is undefined behavior, since the mutex controls access to the object members.

Object members are destroyed after the destructor runs, so I don't see a problem with this code.
Comment 2 Kimmo Kinnunen 2021-04-14 12:03:49 PDT
> > This is undefined behavior, since the mutex controls access to the object members.
> 
> Object members are destroyed after the destructor runs, so I don't see a
> problem with this code.

Yeah, you're right. I took a bit of a mental shortcut, thinking about the case where the mutex would be moved to the class for more logical operation. 

I'll use this bug to remove the comment.
Comment 3 Kimmo Kinnunen 2021-04-14 12:08:11 PDT
Ah, no, maybe not. I think the issue still stands.

> Object members are destroyed after the destructor runs, so I don't see a problem with this code.


It's not about destroying the members.

The bug is about what C++ defines as being "well-formed program".

I think I recall, and it sort of makes sense, that a well-formed program cannot have the execution in destructor and a member function at the same time. In practice it works, as the data members are destroyed after end of the destructor. However, typically one should not rely on "in practice it works" if it's contrary to the soundness definition of the language.
Comment 4 Kimmo Kinnunen 2021-04-14 12:28:51 PDT
Clarified it: I was remembering and thinking wrong.
So I'll remove the comment in the destructor.
Comment 5 Radar WebKit Bug Importer 2021-04-20 05:13:15 PDT
<rdar://problem/76894075>