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

HCR depends on nimcachedir.len #16265

Closed
timotheecour opened this issue Dec 6, 2020 · 2 comments · Fixed by #16329
Closed

HCR depends on nimcachedir.len #16265

timotheecour opened this issue Dec 6, 2020 · 2 comments · Fixed by #16329

Comments

@timotheecour
Copy link
Member

timotheecour commented Dec 6, 2020

[EDIT]
After a painful reduction, I found this bug while working on #13999

--hotCodeReloading "works" or fails depending on the length of nimcachedir (from --nimcache) /cc @zah

That's a serious bug because depending on unrelated changes you'll have something working or not, and it can be hard to debug.

Example

when true:
  import os
  echo commandLineParams()
  • step 1: nim c lib/nimhcr.nim
  • step 2:XDG_CONFIG_HOME= nim c --forceBuild --hotCodeReloading:on -o:/tmp/z13 --hints:off --passl:-Wl,-rpath,lib --skipusercfg --skipparentcfg --nimcache:/tmp/D20201205T1650_D20201205T184232_nimcache10x main.nim

where:

  • XDG_CONFIG_HOME= and --skipusercfg --skipparentcfg are to ignore user's environment
  • --passl:-Wl,-rpath,lib is to avoid runtime error could not load: libnimhcr.dylib

Current Output

/tmp/z13 a1 a2 
@[]

Expected Output

/tmp/z13 a1 a2
@["a1", "a2"]

Additional Information

D20201205T165017
1.5.1 devel edce589

  • it works if not using --hotCodeReloading:on
  • it works if using --nimcache:/tmp/D20201205T1650_nimcache10x, or so long the length of nimcachedir is <= some threshold, then fails after that threshold
@timotheecour timotheecour changed the title whether --nimcache is in a symlink (eg /tmp/dir on osx) affects semantics nim semantics change depending on nimcachedir.len Dec 6, 2020
@timotheecour
Copy link
Member Author

pretty sure it's related to this:

      # nasty nasty hack to get the command line functionality working with HCR
      # register the 2 variables on behalf of the os module which might not even
      # be loaded (in which case it will get collected but that is not a problem)
      let osModulePath = ($systemModulePath).replace("stdlib_system", "stdlib_os").rope
      g.mainDatInit.addf("\thcrAddModule($1);\n", [osModulePath])
      g.mainDatInit.add("\tint* cmd_count;\n")
      g.mainDatInit.add("\tchar*** cmd_line;\n")
      g.mainDatInit.addf("\thcrRegisterGlobal($1, \"cmdCount\", sizeof(cmd_count), NULL, (void**)&cmd_count);$N", [osModulePath])
      g.mainDatInit.addf("\thcrRegisterGlobal($1, \"cmdLine\", sizeof(cmd_line), NULL, (void**)&cmd_line);$N", [osModulePath])
      g.mainDatInit.add("\t*cmd_count = cmdCount;\n")
      g.mainDatInit.add("\t*cmd_line = cmdLine;\n")

timotheecour added a commit to timotheecour/Nim that referenced this issue Dec 6, 2020
…h, in combination with other hacks, caused a really obscure looking bug
timotheecour added a commit to timotheecour/Nim that referenced this issue Dec 6, 2020
…h, in combination with other hacks, caused a really obscure looking bug
@timotheecour
Copy link
Member Author

timotheecour commented Dec 6, 2020

indeed..., I fixed it in timotheecour#424

@Araq Araq changed the title nim semantics change depending on nimcachedir.len HCR depends on nimcachedir.len Dec 6, 2020
timotheecour added a commit to timotheecour/Nim that referenced this issue Dec 11, 2020
…h, in combination with other hacks, caused a really obscure looking bug
timotheecour added a commit to timotheecour/Nim that referenced this issue Dec 13, 2020
…h, in combination with other hacks, caused a really obscure looking bug
Araq pushed a commit that referenced this issue Dec 14, 2020
…ng litterals (#16329)

* fix #16265: cgen now does not line wrap string litterals which, in combination with other hacks, caused a really obscure looking bug

* fix #13999; nimhcr_integration.nim now works for osx

* try to make appveyor CI disappear

* disable openbsd + add diagnostic for openbsd

* enable for openbsd

* PTEMP

* re-disable openbsd
mildred pushed a commit to mildred/Nim that referenced this issue Jan 11, 2021
…t line wrap string litterals (nim-lang#16329)

* fix nim-lang#16265: cgen now does not line wrap string litterals which, in combination with other hacks, caused a really obscure looking bug

* fix nim-lang#13999; nimhcr_integration.nim now works for osx

* try to make appveyor CI disappear

* disable openbsd + add diagnostic for openbsd

* enable for openbsd

* PTEMP

* re-disable openbsd
ardek66 pushed a commit to ardek66/Nim that referenced this issue Mar 26, 2021
…t line wrap string litterals (nim-lang#16329)

* fix nim-lang#16265: cgen now does not line wrap string litterals which, in combination with other hacks, caused a really obscure looking bug

* fix nim-lang#13999; nimhcr_integration.nim now works for osx

* try to make appveyor CI disappear

* disable openbsd + add diagnostic for openbsd

* enable for openbsd

* PTEMP

* re-disable openbsd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment