To: J3 J3/23-208 From: John Reid & Brad Richardson Subject: Interp on finalization Date: 2023-August-11 ---------------------------------------------------------------------- NUMBER: Fxx/xxx TITLE: Finalizations and deallocations of coarrays KEYWORDS: finalization, deallocation, coarray DEFECT TYPE: Erratum STATUS: J3 consideration in progress REFERENCES: N2218 (FDIS) INTRODUCTION We are concerned about a single event causing several final subroutines to be called. This can happen when a deallocate statement is executed and it can happen on return from a procedure that has several local objects that are finalizable. If finalizations that involve coarray synchronizations are not invoked in the same order of all the images of the current team, a race condition may occur. The note in 7.5.6.2 states "An implementation might need to ensure that when an event causes more than one coarray to be deallocated, they are deallocated in the same order on all images in the current team." We think that this wording is based on the belief than many implementations will execute the same object code on all active images so that no special attention is needed to ensure that the final subroutines are called in the same order on each image. We take the view that this should be a requirement. We note that a final subroutine is permitted to contain image control statements other than deallocate. Similar considerations apply to deallocations. QUESTION 1: If an event causes more than one entity to be finalized, are these finalizations made in the same order on all the images of the current team? QUESTION 2: If an event causes more than one coarray to be deallocated, are these deallocations made in the same order on all the images of the current team? ANSWER 1: It was intended that if an event causes more than one entity to be finalized, these finalizations made in the same order on all the images of the current team. An edit is supplied to make this clear. ANSWER 2: It was intended that if an event causes more than one coarray to be deallocated, these deallocatations made in the same order on all the images of the current team. An edit is supplied to make this clear. EDITS to N2218: Question 1 In 7.5.6.2 The finalization process, at the end of the penultimate sentence add ", but each image in the current team shall perform the finalizations of those entities in the same order" so that the sentence reads "If several entities are to be finalized as a consequence of an event specified in 7.5.6.3, the order in which they are finalized is processor dependent, but each image in the current team shall perform the finalizations of those entities in the same order." Question 2 In 9.7.3.1 Form of the DEALLOCATE statement, final paragraph after "statement" add "or as a consequence of an event specified in 9.7.3.2" and at the end of the sentence add ", but each image in the current team shall perform the deallocations of those objects in the same order" so that the paragraph reads "When more than one allocated object is deallocated by execution of a DEALLOCATE statement or as a consequence of an event specified in 9.7.3.2, the order of deallocation is processor dependent, but each image in the current team shall perform the deallocations of those objects in the same order." SUBMITTED BY: John Reid & Brad Richardson HISTORY: 23-xxx m231 Submitted ----------------------------------------------------------------------