Bug 224480

Summary: Remove the comment in ~AudioSourceProviderAVFObjC about undefined behavior
Product: WebKit Reporter: Kimmo Kinnunen <kkinnunen>
Component: MediaAssignee: Kimmo Kinnunen <kkinnunen>
Status: ASSIGNED ---    
Severity: Normal CC: ap, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Local Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 224230    
Bug Blocks:    

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>