Skip to content
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

gorge(Ex) fails after a few calls on OSX #12337

Closed
genotrance opened this issue Oct 2, 2019 · 4 comments
Closed

gorge(Ex) fails after a few calls on OSX #12337

genotrance opened this issue Oct 2, 2019 · 4 comments

Comments

@genotrance
Copy link
Contributor

Reproduced on 0.19.6 - devel on OSX only.

Failure linked above is because gorgeEx returns output of "" and error code -1. Failing line of code is here. bash exists on OSX but gorgeEx does not even run. From the code, looks like we are getting an OSError or IOError.

I created a simpler snippet that fails consistently on my OSX laptop at the 123rd iteration.

import macros

proc run(): string =
  for i in 0 .. 200:
    let (x, y) = gorgeEx("which bash")
    doAssert y == 0, "Failed in loop " & $i & ", return value was " & $y
    result &= x & "\n"

macro gen(): untyped =
  var
    name = newIdentNode("abc")
  result = newNimNode(nnkStmtList)
  result.add(quote do:
    const `name` = run()
  )

  echo result.repr

gen()

echo abc

Curious how to debug further.

@genotrance
Copy link
Contributor Author

Okay, here's the error stack.

/nimdevel/compiler/nim.nim(106) nim
/nimdevel/compiler/nim.nim(83) handleCmdLine
/nimdevel/compiler/cmdlinehelper.nim(98) loadConfigsAndRunMainCommand
/nimdevel/compiler/main.nim(188) mainCommand
/nimdevel/compiler/main.nim(92) commandCompileToC
/nimdevel/compiler/modules.nim(145) compileProject
/nimdevel/compiler/modules.nim(86) compileModule
/nimdevel/compiler/passes.nim(210) processModule
/nimdevel/compiler/passes.nim(86) processTopLevelStmt
/nimdevel/compiler/sem.nim(597) myProcess
/nimdevel/compiler/sem.nim(565) semStmtAndGenerateGenerics
/nimdevel/compiler/semstmts.nim(2187) semStmt
/nimdevel/compiler/semexprs.nim(984) semExprNoType
/nimdevel/compiler/semexprs.nim(2733) semExpr
/nimdevel/compiler/semstmts.nim(2127) semStmtList
/nimdevel/compiler/semexprs.nim(2630) semExpr
/nimdevel/compiler/semexprs.nim(966) semDirectOp
/nimdevel/compiler/semexprs.nim(858) afterCallActions
/nimdevel/compiler/sem.nim(468) semMacroExpr
/nimdevel/compiler/sem.nim(411) semAfterMacroCall
/nimdevel/compiler/semexprs.nim(2733) semExpr
/nimdevel/compiler/semstmts.nim(2127) semStmtList
/nimdevel/compiler/semexprs.nim(2737) semExpr
/nimdevel/compiler/semstmts.nim(596) semConst
/nimdevel/compiler/sem.nim(354) semConstExpr
/nimdevel/compiler/vm.nim(2029) evalConstExpr
/nimdevel/compiler/vm.nim(2025) evalConstExprAux
/nimdevel/compiler/vm.nim(1082) rawExecute
/nimdevel/compiler/vmops.nim(93) gorgeExWrapper
/nimdevel/compiler/gorgeimpl.nim(51) opGorge
/nimdevel/lib/pure/osproc.nim(899) startProcess
/nimdevel/lib/pure/os.nim(1209) getCurrentDir
/nimdevel/lib/pure/includes/oserr.nim(94) raiseOSError
Error: unhandled exception: Too many open files [OSError]

@zevv
Copy link
Contributor

zevv commented Oct 2, 2019

Verified with strace, gorge leaks fds at compile time.

zevv added a commit to zevv/Nim that referenced this issue Oct 2, 2019
rayman22201 pushed a commit to rayman22201/Nim that referenced this issue Oct 4, 2019
@genotrance
Copy link
Contributor Author

@narimiran - was this not backported to 1.0.2?

@narimiran
Copy link
Member

The PR/commit didn't have the [backport] tag. I can backport it manually so it will be in 1.0.4

narimiran pushed a commit that referenced this issue Oct 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants