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

Application crashes with exit code -1073740940 when using orc and useMalloc but it works only with orc #24205

Open
forchid opened this issue Sep 30, 2024 · 0 comments

Comments

@forchid
Copy link

forchid commented Sep 30, 2024

Test source

import std/os
#import std/strformat
import strutils

type
  ObjRef = ref object of RootObj
    data: int
    remark: string
    parent: ObjRef
    children: seq[ObjRef]
   
proc test(o: ObjRef, i: int) =
    #echo "data = ", o.data
    var o = new(ObjRef)
    o.data = i
    #o.remark = fmt"*ObjRef*#{i}Foo-bar-foo-bar-foo-bar#{i}"
    var c = ObjRef(data: i + 1)
    o.children.add(c)
    c.parent = o
    o.children = @[]
  
proc printDiagnostics() =
  echo("Total memory available: " & formatSize(getTotalMem()) & " bytes")
  echo("Free memory: " & formatSize(getFreeMem()) & " bytes")
  echo("Occupied memory: " & formatSize(getOccupiedMem()) & " bytes")
   
proc main =
    var
        o: ObjRef
        #i = 0
        n = 100000000
        #a = initSinglyLinkedList[ObjRef]()
        a = newSeq[ObjRef]()

    #while i <= n:
    for i in 1 .. n + 1:
        #inc i
        o = new(ObjRef)
        o.data = i
        #o.remark = fmt"ObjRef#{i}Foo-bar-foo-bar-foo-bar#{i}"
        var c = ObjRef(data: i + 1)
        o.children.add(c)
        c.parent = o;
        o.test(i)
        a.add(o)
  
        if i mod 1000_0000 == 0:
            #a = initSinglyLinkedList[ObjRef]()
            for item in a: item.children = @[]
            a = @[]
  
        if i mod 10000000 == 0:
            echo "i = ", i
            o.test(i)
            printDiagnostics();

main()

const STM = 1000
for i in 1 .. 1800:
    printDiagnostics();
    echo $i & ". Sleep " & $STM & "ms"
    sleep(STM)
echo "Bye!"

Nim Version

nim -v
Nim Compiler Version 1.6.20 [Windows: amd64]
Compiled at 2024-04-07
Copyright (c) 2006-2023 by Andreas Rumpf

active boot switches: -d:release

%nim20_home%\bin\nim -v
Nim Compiler Version 2.0.8 [Windows: amd64]
Compiled at 2024-07-03
Copyright (c) 2006-2023 by Andreas Rumpf

active boot switches: -d:release

Current Output

>%nim20_home%\bin\nim c -d:release --mm:orc -d:useMalloc --stackTrace:on objtest.nim
>objtest

>echo %errorlevel%
-1073740940

Expected Output

>%nim20_home%\bin\nim c -d:release --mm:orc --stackTrace:on objtest.nim
>objtest
i = 10000000
Total memory available: 2.363GiB bytes
Free memory: 2.191GiB bytes
Occupied memory: 175.993MiB bytes
i = 20000000
Total memory available: 2.789GiB bytes
Free memory: 2.531GiB bytes
Occupied memory: 263.997MiB bytes
i = 30000000
Total memory available: 2.789GiB bytes
Free memory: 2.531GiB bytes
Occupied memory: 263.997MiB bytes
...

Known Workarounds

No response

Additional Information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants