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).
On my machine, any value of Limit below 523.6k always works, and any value of Limit above 524k always segfaults. Any Limit value within that range can go either way.
To help track this range down, this Python 3 script might be useful
```python
import subprocess
lo = 0
hi = 1_000_000
def worked(limit: int) -> bool:
p = subprocess.run(
[
'nim',
'compile',
'--gc:arc',
'--run',
'-d:useMalloc',
'-d:Limit={}'.format(limit),
'-d:Content="abc"',
'-d:release',
'ropetest.nim',
],
stderr=subprocess.DEVNULL
)
try:
p.check_returncode()
except subprocess.CalledProcessError:
return False
else:
return True
while lo < hi - 1:
print(lo, hi)
mid = (lo + hi) // 2
if worked(mid):
lo = mid
else:
hi = mid
assert hi - 1 <= lo <= hi
for i in range(hi+5, hi-5, -1):
if worked(i):
print('Final:', i)
break
```
Expected Output
Since 600k copies of the string "abc" is less than 2Mb, I would expect this to never segfault.
Additional Information
Git hash cfe19247e856950f7facaf7adbc50bca8dec3990
$ nim -v
Nim Compiler Version 1.5.1 [Linux: amd64]
Compiled at 2021-05-30
Copyright (c) 2006-2021 by Andreas Rumpf
git hash: cfe19247e856950f7facaf7adbc50bca8dec3990
active boot switches: -d:release
Using
--gc:arc
or--gc:orc
withropes
produces a segmentation fault at values ofLimit
>= 524k, but--gc:none
and--gc:refc
do not.Example
Current Output
Using
-d:Limit=600_000
100% failure rate.
Neither
-d:Content:""
nor-d:useMalloc
make any difference.Using
-d:Limit=500_000
At smaller values, however, both
--gc:none
and--gc:arc
pass. 100% success rate.Smallest
Limit
On my machine, any value of
Limit
below 523.6k always works, and any value ofLimit
above 524k always segfaults. AnyLimit
value within that range can go either way.To help track this range down, this Python 3 script might be useful
```python import subprocess lo = 0 hi = 1_000_000 def worked(limit: int) -> bool: p = subprocess.run( [ 'nim', 'compile', '--gc:arc', '--run', '-d:useMalloc', '-d:Limit={}'.format(limit), '-d:Content="abc"', '-d:release', 'ropetest.nim', ], stderr=subprocess.DEVNULL ) try: p.check_returncode() except subprocess.CalledProcessError: return False else: return True while lo < hi - 1: print(lo, hi) mid = (lo + hi) // 2 if worked(mid): lo = mid else: hi = mid assert hi - 1 <= lo <= hi for i in range(hi+5, hi-5, -1): if worked(i): print('Final:', i) break ```Expected Output
Since 600k copies of the string
"abc"
is less than 2Mb, I would expect this to never segfault.Additional Information
Git hash cfe19247e856950f7facaf7adbc50bca8dec3990