-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Files missing during compilation #115
Comments
I have had it happen a lot on Windows 10, Windows XP, Cent OS VMs and also on my normal Linux Mint machine. |
I wonder if this could be what I have been noticing with my windows machines
I checked out the differences between git bcc, and bmk against my local copy and the only difference was my make.bmk where I added globals.SetOption(“cc_opts”, “optimization”, “-Os”) in default_cc_opts
Side note: I had to add it to make.bmk because for some reason setting anything in core.bmk appears to be ignored on windows, but then again this could be an isolated incident, as no one else has ever reported anything.
I was going to try out -flto but decided against it in case there were any side effects but even so using -Os produces a rather nice compact executable
|
I had this happen on default installs.
Means: either official releases or official releases updated with more current modules and bcc/bmk builds.
Your reported issue might be a separate one. That ignored stuff in bmk files should be reported individually so people can try to replicate that.
|
Can it be that in multithreaded processing files are not finished writing but bmk already continued?
Tried again:
as if bmk does not wait for some files to be generated properly - it executes the command (eg calls GCC) but does not wait for the results to exist/processes to be finished. |
In commit 2fdd34d @woollybah changed something which made something in the "diff" visible I was not aware of before:
After starting the process bmk starts a while loop - and in there it waits 10 milliseconds. it waits before even trying to read the first line. Means even if "start process + availability of first line" is happening in the first millisecond, it will ALWAYS wait 10 milliseconds. So .. why was it done that way? why not delay "later" ? OK ... so what made me stumble there? The time. In multithreaded builds time is crucial ... and timing even more. So my thoughts now were moving toward this idea and assumption:
BCC uses Sidenode:
BTW While the file is written it can be accessed (regarding "mtime"). So what does that mean? Checks in "bcc" or "bmk" regarding "filetime" can lead to decisions based on "currently being written" files. This means it could eg. think "a file is there" which is in that very moment not complete. Consider this sample code here: SuperStrict
Framework Brl.StandardIO
Import Brl.Threads
Import Brl.Filesystem
Import Brl.TextStream
Function ThreadFunc:Object( data:Object )
Local s:TStream = WriteStream("filemtime.txt")
'write "header"
s.WriteByte $ef
s.WriteByte $bb
s.WriteByte $bf
'wrap in a second stream
Local s2:TTextStream=TTextStream.Create(s, ETextStreamFormat.UTF8)
'do some work
For Local i:Int = 1 To 5
s2.WriteString("Hello~n")
Delay(500)
Next
s2.Close()
s.Close()
Return "done."
End Function
If FileType("filemtime.txt") = FILETYPE_FILE
Print "existing file mtime = " + FileTime("filemtime.txt")
EndIf
Local fileThread:TThread = CreateThread(ThreadFunc, "")
For Local i:Int = 1 To 5
If FileType("filemtime.txt") = FILETYPE_FILE
Print "Step " + i + ": file mtime = " + FileTime("filemtime.txt")
Print "Content: " + LoadText("filemtime.txt")
EndIf
Delay(500)
Next
WaitThread( fileThread )
Print "File thread is done. file mtime = " + FileTime("filemtime.txt")
Print "Content: " + LoadText("filemtime.txt") Running it results here in this output:
See four important things (run the code twice to have the first part printed):
TL/DR:The conclusion of my thought is: The discrepancy between "Filetime()" and an "actually useable file" might lead to the issue we see here: files not being found. BUT ... I am not sure how it works out with "append" file modes, yet I think we do not "append" in bmk or bcc. |
Continuing this the thought above - and tinkering about solutions: Any thread writing "files" could write to a global "currentlyProcessedFiles"-container. Before starting it adds, and after finishing it removes (with mutex protection etc). This way any thread can check if the file of interest is currently "rewritten" by someone else. External commands can only be started with specific filenames in the params, if the filenames do not exist in the "currentlyProcessedFiles"-container. This avoids to hand out "gcc" currently open files. BUT ... it might be worth to check first what happens if you pass GCC files which are "currently open". Same to say about files, GCC creates (the o files?). Files might still be written by the OS while BMK or BCC think GCC is done (process ended). I think Brucey knows best about the order of executed commands, when which file is created and when external processes are run etc. So maybe my "findings" are not suitable here. |
I got reports by users - and also saw it pretty often in VMs, think it happens more often on Windows and Mac than on Linux:
As it happens more often on Windows and Mac - it means it runs (on my computers) either on an old Mac or inside a VM.
This points a bit into a "collision" issue of threads. My computer is speedier and the discs are faster - so stuff just might not "collide".
Will try to find some time to investigate what happens
The text was updated successfully, but these errors were encountered: