SIGSEGV during compilation with parallel block #2758

Closed
Xaseron opened this Issue May 18, 2015 · 1 comment

Projects

None yet

3 participants

@Xaseron
Contributor
Xaseron commented May 18, 2015

% nim c --threads:on msort.nim :(
/etc/nim.cfg(53, 3) Hint: added path: '/home/xaseron/.babel/pkgs/' [Path]
/etc/nim.cfg(54, 3) Hint: added path: '/home/xaseron/.nimble/pkgs/gtk2-1.0' [Path]
/etc/nim.cfg(54, 3) Hint: added path: '/home/xaseron/.nimble/pkgs/cairo-1.0' [Path]
/etc/nim.cfg(54, 3) Hint: added path: '/home/xaseron/.nimble/pkgs/' [Path]
Hint: used config file '/etc/nim.cfg' [Conf]
Hint: system [Processing]
Hint: msort [Processing]
Hint: threadpool [Processing]
Hint: cpuinfo [Processing]
Hint: strutils [Processing]
Hint: parseutils [Processing]
Hint: os [Processing]
Hint: times [Processing]
Hint: posix [Processing]
Hint: linux [Processing]
Hint: cpuload [Processing]
Hint: locks [Processing]
lib/nim/core/locks.nim(22, 44) Warning: LockEffect is deprecated [Deprecated]
lib/nim/core/locks.nim(25, 45) Warning: LockEffect is deprecated [Deprecated]
Hint: math [Processing]
Hint: sequtils [Processing]
SIGSEGV: Illegal storage access. (Attempt to read from nil?)

import threadpool
import math
import sequtils
import times

proc merge[T](left, right: seq[T]): seq[T] =
    result = newSeq[T]()
    var li, ri = 0
    while li < left.len and ri < right.len:
        if left[li] < right[ri]:
            result.add(left[li])
            inc li
        else:
            result.add(right[ri])
            inc ri
    while li < left.len:
        result.add(left[li])
        inc li
    while ri < right.len:
        result.add(right[ri])
        inc ri

proc mergeSort[T](arr: seq[T]): seq[T] =
    if arr.len <= 1:
        return arr
    let middle = int arr.len / 2

    parallel:
        let left = spawn arr[arr.low .. middle-1]
        let right = spawn arr[middle .. arr.high]

    let l1 = mergeSort(^left)
    let r1 = mergeSort(^right)

    result = merge(l1, r1)

randomize(int(epochTime()))
var a = newSeqWith(10_000_000, random(235234234))


let x = mergeSort a
@Xaseron Xaseron changed the title from SIGSEV during compilation to SIGSEGV during compilation May 18, 2015
@dom96
Member
dom96 commented May 19, 2015

Stack trace (Possibly using an significantly outdated nim compiler)

Traceback (most recent call last)
nim.nim(94)              nim
nim.nim(56)              handleCmdLine
main.nim(251)            mainCommand
main.nim(62)             commandCompileToC
modules.nim(203)         compileProject
modules.nim(151)         compileModule
passes.nim(197)          processModule
passes.nim(137)          processTopLevelStmt
cgen.nim(1211)           myProcess
ccgstmts.nim(1080)       genStmts
ccgexprs.nim(2066)       expr
ccgstmts.nim(1080)       genStmts
ccgexprs.nim(2066)       expr
ccgstmts.nim(1080)       genStmts
ccgexprs.nim(2130)       expr
cgen.nim(781)            genProc
cgen.nim(751)            genProcNoForward
cgen.nim(678)            genProcAux
ccgstmts.nim(1080)       genStmts
ccgexprs.nim(2066)       expr
ccgstmts.nim(1080)       genStmts
ccgexprs.nim(2066)       expr
ccgstmts.nim(1080)       genStmts
ccgexprs.nim(2029)       expr
ccgexprs.nim(1744)       genMagicExpr
semparallel.nim(485)     liftParallel
semparallel.nim(446)     transformSpawn
semparallel.nim(412)     transformSpawnSons
semparallel.nim(431)     transformSpawn
lowerings.nim(499)       wrapProcForSpawn
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
@dom96 dom96 changed the title from SIGSEGV during compilation to SIGSEGV during compilation with parallel block May 19, 2015
@dom96 dom96 added the Semcheck label May 19, 2015
@Araq Araq added the Crash label May 31, 2016
@Araq Araq added a commit that closed this issue Jul 15, 2016
@Araq Araq fixes #2758 153fd13
@Araq Araq closed this in 153fd13 Jul 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment