[Bug 756] New: Swift array closing ambiguity
https://bugzilla.mcs.anl.gov/swift/show_bug.cgi?id=756 Summary: Swift array closing ambiguity Product: Swift Version: 0.93 Platform: PC OS/Version: Mac OS Status: NEW Severity: normal Priority: P2 Component: SwiftScript language AssignedTo: [email protected] ReportedBy: [email protected] I think from tests its the case that Swift fully closes an array when its returned from a function, but also allows modifications to that array by statements outside of the function that returns the array. I think this can lead to race conditions but dont yet have a test case that shows this. Im filing this so we dont loose track of this potential bug. The example below is one of a few variations. I think Tim may have reported similar issues when he first started testing Swift array semantics. ============================ com$ cat t1.race.swift (int a[]) fill() { a = [1:9]; } int out[]; if (1==1) { foreach i in [1] { out[0] = 123; } trace("in if",out); } if(2==2) { out = fill(); trace("in if-2",out); } if(3==3) { trace("END",out); } com$ swift t1.race.swift no sites file specified, setting to default: /home/wilde/swift/rev/trunk/etc/sites.xml Swift trunk swift-r5651 cog-r3361 RunID: 20120316-1731-z81sk1fd Progress: time: Fri, 16 Mar 2012 17:31:15 -0500 Execution failed: out is closed with a value of 123 com$ swift t1.race.swift no sites file specified, setting to default: /home/wilde/swift/rev/trunk/etc/sites.xml Swift trunk swift-r5651 cog-r3361 RunID: 20120316-1731-kvy0rel1 Progress: time: Fri, 16 Mar 2012 17:31:25 -0500 Execution failed: out is closed with a value of 123 com$ swift t1.race.swift no sites file specified, setting to default: /home/wilde/swift/rev/trunk/etc/sites.xml Swift trunk swift-r5651 cog-r3361 RunID: 20120316-1731-fxpisskc Progress: time: Fri, 16 Mar 2012 17:31:29 -0500 Execution failed: out is closed with a value of 123 com$ swift t1.race.swift no sites file specified, setting to default: /home/wilde/swift/rev/trunk/etc/sites.xml Swift trunk swift-r5651 cog-r3361 RunID: 20120316-1731-8jf41jq7 Progress: time: Fri, 16 Mar 2012 17:31:33 -0500 SwiftScript trace: in if-2, {0 = 1, 1 = 2, 2 = 3, 3 = 4, 4 = 5, 5 = 6, 6 = 7, 7 = 8, 8 = 9} SwiftScript trace: END, {0 = 1, 1 = 2, 2 = 3, 3 = 4, 4 = 5, 5 = 6, 6 = 7, 7 = 8, 8 = 9} SwiftScript trace: in if, {0 = 1, 1 = 2, 2 = 3, 3 = 4, 4 = 5, 5 = 6, 6 = 7, 7 = 8, 8 = 9} Execution failed: out is closed with a value of 1 com$ swift t1.race.swift no sites file specified, setting to default: /home/wilde/swift/rev/trunk/etc/sites.xml Swift trunk swift-r5651 cog-r3361 RunID: 20120316-1731-a5vb891f Progress: time: Fri, 16 Mar 2012 17:31:56 -0500 Execution failed: out is closed with a value of 123 com$ swift t1.race.swift no sites file specified, setting to default: /home/wilde/swift/rev/trunk/etc/sites.xml Swift trunk swift-r5651 cog-r3361 RunID: 20120316-1731-hhkppxn0 Progress: time: Fri, 16 Mar 2012 17:32:00 -0500 Execution failed: out is closed with a value of 123 com$ swift t1.race.swift no sites file specified, setting to default: /home/wilde/swift/rev/trunk/etc/sites.xml Swift trunk swift-r5651 cog-r3361 RunID: 20120316-1732-tupc3xi9 Progress: time: Fri, 16 Mar 2012 17:32:04 -0500 Execution failed: out is closed with a value of 123 com$ com$ -- Configure bugmail: https://bugzilla.mcs.anl.gov/swift/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are watching all bug changes.
https://bugzilla.mcs.anl.gov/swift/show_bug.cgi?id=756 Mihael Hategan <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID --- Comment #1 from Mihael Hategan <[email protected]> 2012-07-17 15:40:56 --- Right. Writing to an array is allowed in multiple places. Swift keeps track of all the places an array is written to and only closes it when all those places return/finish execution. It is generally impossible to ensure at compile-time that writes to the same index do not occur, so this check is done at run-time. If the same element of an array is written to in two (or more) places, then there is an ambiguity as to which one will do the write first. However, that is an invalid condition, and a script cannot successfully complete in that case. If only one writer exists, then there is no such ambiguity. The bottom line is that there is no such race condition for valid programs. -- Configure bugmail: https://bugzilla.mcs.anl.gov/swift/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are watching all bug changes.
participants (1)
-
bugzilla-daemon@mcs.anl.gov