nim-routine icon indicating copy to clipboard operation
nim-routine copied to clipboard

Strange -only --gc:none is stable

Open KMiNT21 opened this issue 7 years ago • 1 comments

I'm not sure if it lib or Nim or I do something wrong, but after many hours I can't find the place...

I simplified my code ~ to this TEST example. So it runs 250 tasks and from time to time crashed with: Error: execution of an external program failed: (path) It stops before line "echo "Finished.""

If I use --gc:none - it works stable every start. But I can't understand where can be problem with GC ...

...
let files_dir = "some-folder-with-txt-files"
let files_to_process = lc[f | (f <- walkFiles(files_dir & "/*.txt")), string]
...
const my_limit = 250
...
let my_files = files_to_process[0..my_limit-1]

proc process(ch: MsgBox[int], file_path: string) {.routine.} =
    let data = readFile(file_path)
    let s = len(data.splitlines())

echo "Starting.."

for i in 0..my_limit-1:
  pRun process, (boxes[i], my_files[i])
waitAllRoutine()

echo "Finished."

nim c -w:off --hints:off --verbosity:0 --threads:on -r rtest.nim

If I remove waitAllRoutine() - no errors, but if I put sleep(5000) instead to give time for threads - ERROR back again some times. So problem somewhere it threads switching.

KMiNT21 avatar Jan 19 '19 20:01 KMiNT21

Sorry, this lib is not maintained to catch NIM's latest changes for years. It's quite a surprise to know that people are still using it. Thank you for the trust.

I'm not sure I have bandwidth to fix it in time. Do you mind to put this case in the test dir and help debug the lib? :) A PR is quite welcome.

rogercloud avatar Jan 21 '19 04:01 rogercloud