nim-lang / Nim

Nim is a statically typed compiled systems programming language. It combines successful concepts from mature languages like Python, Ada and Modula. Its design focuses on efficiency, expressiveness, and elegance (in that order of priority).
https://nim-lang.org
Other
16.55k stars 1.47k forks source link

C1060 error (heap exhausted) during compilation by VS2019 #11613

Open Toshiyuki-Tega opened 5 years ago

Toshiyuki-Tega commented 5 years ago

While installing winim 3.1.1 using nimble with vcc frontend (VS 2019), C1060 error (heap exhausted) occurs at winimx.nim.

Example

> nimble install winim
Downloading https://github.com/khchen/winim using git
...(omitted)
        ... CC: winimx.nim
        ... Error: execution of an external compiler program 'vccexe.exe /c --platform:amd64 -DWIN32_LEAN_AND_MEAN /O2  /ID:\Projects\Nim\lib /IC:\Users\tega\AppData\Local\Temp\nimble_20324\githubcom_khchenwinim\winim /FoC:\Users\tega\nimcache\winimx_r\winimx.nim.c.obj C:\Users\tega\nimcache\winimx_r\winimx.nim.c' failed with exit code: 2
        ... Microsoft(R) C/C++ Optimizing Compiler Version 19.21.27702.2 for x64
        ... Copyright (C) Microsoft Corporation.  All rights reserved.
        ... winimx.nim.c
        ... C:\Users\tega\nimcache\winimx_r\winimx.nim.c(28299): fatal error C1060: heap exhausted (<--- it was actually in Japanese)

Possible Solution

Not sure, but it works fine when gcc (mingw) frontend is used.

Additional Information

  const winimDb = staticRead("lib/winim.db")

In winimx.nim, there's a 2MB file embedded using staticRead. It may be a direct/indirect cause of the problem.

nim compiler from current devel branch is used on Windows 10 x64 Japanese.

> nim -v
Nim Compiler Version 0.20.99 [Windows: amd64]
Compiled at 2019-06-28
Copyright (c) 2006-2019 by Andreas Rumpf

git hash: d72edfb14b5ed7fcfa0eaf63e8e291d48847ba25
active boot switches: -d:release
cheatfate commented 5 years ago

It looks like winim problem, also i would not recommend to anybody to use opensource projects which has compressed binary blobs inside, its unsafe.

khchen commented 3 years ago

No, it is not winim's problem. The problem is because that if you load a large by staticRead, the generated C code won't be accepted by VCC. GCC and TCC don't have this problem. This problem is still exsits in nim compiler 1.4.0.

BTW, winim is safe.