Hi Marcel, Hi Dave,<br>
<br>
I don't see why you would expect this to work. The normal SourceFiles array already contains a writable pointer to the changes file, so of course it cannot be opened writable again. There can only be one writable pointer to a file at one time, at least on Windows. I am more surprised that this rule does not apply on Linux/macOS.<br>
<br>
On Windows, apparently we need to close the changes file before re-opening it. We can either implement this manually or apply my proposed patch instead, because even conceptually, I don't see a real sense in making #openSourceFiles itself idempotent. :-)<br>
<br>
Dave, you were probably unable to reproduce this in a debugger because once you have replaced the SourceFiles with a read-only pointer and old pointer has been GC'ed, the issue does not occur any longer. There is no limit for parallel read-only pointers on a file.<br>
<br>
Best,<br>
Christoph<br>
<br>
<font color="#808080">---<br>
</font><font color="#808080"><i>Sent from </i></font><font color="#808080"><i><a href="https://github.com/hpi-swa-lab/squeak-inbox-talk"><u><font color="#808080">Squeak Inbox Talk</font></u></a></i></font><br>
<br>
On 2022-01-11T19:12:18-05:00, lewis@mail.msen.com wrote:<br>
<br>
> Strange indeed. I tried on a Windows machine, and find that<br>
> "Smalltalk openSourceFiles" raises an incorrect(?) warning about<br>
> read-only changes file. But when I step through it in a debugger,<br>
> everything works correctly and there is no warning.<br>
> <br>
> I cannot look into it further, but something seems wrong here.<br>
> <br>
> Dave<br>
> <br>
> <br>
> On Tue, Jan 11, 2022 at 10:19:08AM +0100, Marcel Taeumel wrote:<br>
> > Hi Christoph --<br>
> > <br>
> > This looks strange. Why shouldn't this work on Windows? What's your explanation? Let's not fix the symptom but the cause, please.<br>
> > <br>
> > -1<br>
> > <br>
> > Best,<br>
> > Marcel<br>
> > Am 10.01.2022 22:44:42 schrieb christoph.thiede at student.hpi.uni-potsdam.de <christoph.thiede at student.hpi.uni-potsdam.de>:<br>
> > Hi Dave, hi all,<br>
> > <br>
> > please take a short look at this changeset that I would like to merge into the Trunk in order to fix the DoItTest for Windows. Currently, some of them fail because DoItFirst tries to re-open the source files.<br>
> > <br>
> > =============== Summary ===============<br>
> > <br>
> > Change Set:????????????????DoItFirstAfterStartup<br>
> > Date:????????????????????????10 January 2022<br>
> > Author:????????????????????????Christoph Thiede<br>
> > <br>
> > This changeset fixes the DoItFirst tests on Windows by making sure that no attempt is made to re-open the source fiels while the image has already been started up. This is achieved by extracting FileDirectory startUpDefaultDirectory from FileDirectory startUp and only sending the latter from DoItFirst >> #parse:.<br>
> > <br>
> > =============== Diff ===============<br>
> > <br>
> > DoItFirst>>parse: {evaluating} ?? ct 1/10/2022 22:37 (changed)<br>
> > parse: argumentList<br>
> > ????????"Iterate over the argument list, creating actions blocks. Register each action<br>
> > ????????block in the actions dictionary, and collect a list of the actions blocks to be<br>
> > ????????evaluated now. If any action blocks will require files or directory initialization,<br>
> > ????????send the appropriate startUp messages. Answer the list of action blocks to<br>
> > ????????be evaluated."<br>
> > <br>
> > ????????| args listOfBlocks needsFiles needsDirectory |<br>
> > ????????needsFiles := needsDirectory := false.<br>
> > ????????args := argumentList readStream.<br>
> > ????????listOfBlocks := OrderedCollection new.<br>
> > ????????[ args atEnd ] whileFalse: [ | key |<br>
> > ????????????????(key := self keyFor: args next) caseOf: {<br>
> > ????????????????????????[ #help ] -> [ self addFirst: [ self help ] to: listOfBlocks at: key. needsFiles := true] .<br>
> > ????????????????????????[ #debug ] -> [ self addWithoutEvaluation: [ self debug ] at: key] .<br>
> > ????????????????????????[ #doit ] -> [ | list | list := self nextTokensFrom: args. self add:[ self doIt: list ] to: listOfBlocks at: key. needsFiles := true] .<br>
> > ????????????????????????[ #evaluate ] -> [ | arg | arg := args next. self add:[ self evaluateOption: arg ] to: listOfBlocks at: key. needsFiles := true] .<br>
> > ????????????????????????[ #file ] -> [ | arg | arg := args next. self add:[ self evaluateFileContents: arg ] to: listOfBlocks at: key. needsFiles := true] .<br>
> > ????????????????????????[ #filein ] -> [ | list | list := self nextTokensFrom: args. self add:[ self fileIn: list ] to: listOfBlocks at: key. needsFiles := needsDirectory := true] .<br>
> > ????????????????????????[ #cwd ] -> [ | arg | arg := args next. self addFirst:[ self cwd: arg ] to: listOfBlocks at: key. needsFiles := needsDirectory := true] .<br>
> > ????????????????} otherwise: [] ].<br>
> > ????????needsFiles ifTrue: [ FileStream startUp: true. "initialize stdout and stderr" ].<br>
> > - ????????needsDirectory ifTrue: [ FileDirectory startUp "set default directory" ].<br>
> > + ????????needsDirectory ifTrue: [ FileDirectory startUpDefaultDirectory ].<br>
> > ????????^ listOfBlocks.<br>
> > <br>
> > <br>
> > FileDirectory class>>startUp {name utilities} ?? ct 1/10/2022 22:37 (changed)<br>
> > startUp<br>
> > - ????????"Establish the platform-specific FileDirectory subclass. Do any platform-specific startup."<br>
> > - ????????self setDefaultDirectoryClass.<br>
> > <br>
> > - ????????self setDefaultDirectory: (self dirPathFor: Smalltalk imageName).<br>
> > -<br>
> > - ????????Preferences startInUntrustedDirectory<br>
> > - ????????????????ifTrue:[????????"The SecurityManager may override the default directory to prevent unwanted write access etc."<br>
> > - ????????????????????????????????self setDefaultDirectory: SecurityManager default untrustedUserDirectory.<br>
> > - ????????????????????????????????"Make sure we have a place to go to"<br>
> > - ????????????????????????????????DefaultDirectory assureExistence].<br>
> > + ????????self startUpDefaultDirectory.<br>
> > ????????Smalltalk openSourceFiles.<br>
> > - ????????(Smalltalk classNamed: #DoItFirst) ifNotNil: [ :doit | doit perform: #reevaluateCwd ].<br>
> > <br>
> > <br>
> > FileDirectory class>>startUpDefaultDirectory {name utilities} ?? ct 1/10/2022 22:37<br>
> > + startUpDefaultDirectory<br>
> > + ????????"Establish the platform-specific FileDirectory subclass. Do any platform-specific startup."<br>
> > +<br>
> > + ????????self setDefaultDirectoryClass.<br>
> > + ????????self setDefaultDirectory: (self dirPathFor: Smalltalk imageName).<br>
> > +<br>
> > + ????????Preferences startInUntrustedDirectory<br>
> > + ????????????????ifTrue:[????????"The SecurityManager may override the default directory to prevent unwanted write access etc."<br>
> > + ????????????????????????????????self setDefaultDirectory: SecurityManager default untrustedUserDirectory.<br>
> > + ????????????????????????????????"Make sure we have a place to go to"<br>
> > + ????????????????????????????????DefaultDirectory assureExistence].<br>
> > + ????????<br>
> > + ????????(Smalltalk classNamed: #DoItFirst) ifNotNil: [ :doit | doit perform: #reevaluateCwd ].<br>
> > <br>
> > Best,<br>
> > Christoph<br>
> > <br>
> > ---<br>
> > Sent from Squeak Inbox Talk [https://github.com/hpi-swa-lab/squeak-inbox-talk]<br>
> > ["DoItFirstAfterStartup.1.cs"]<br>
> ><br>
> <br>