Open euantorano opened 5 years ago
The stacktrace isn't super helpful because check
is a template, not a proc, so it can't (currently! refs https://github.com/timotheecour/Nim/issues/447) tell which line it was called from:
template check(expr) =
if not expr:
raiseOSError(osLastError())
but as I saw in https://github.com/nim-lang/Nim/pull/16329 it actually points to one of these failing:
check mprotect
or check posix_madvise
proc setLen*(m: var ReservedMem, newLen: int) =
let len = m.len
m.usedMemEnd = m.memStart.shift(newLen)
if newLen > len:
let d = distance(m.committedMemEnd, m.usedMemEnd)
if d > 0:
let commitExtensionSize = nextAlignedOffset(d, allocationGranularity)
when defined(windows):
check virtualAlloc(m.committedMemEnd, commitExtensionSize,
MEM_COMMIT, m.accessFlags.cint)
else:
check mprotect(m.committedMemEnd, commitExtensionSize,
m.accessFlags.cint) == 0
else:
let d = distance(m.usedMemEnd, m.committedMemEnd) -
m.maxCommittedAndUnusedPages * allocationGranularity
if d > 0:
let commitSizeShrinkage = nextAlignedOffset(d, allocationGranularity)
let newCommitEnd = m.committedMemEnd.shift(-commitSizeShrinkage)
when defined(windows):
check virtualFree(newCommitEnd, commitSizeShrinkage, MEM_DECOMMIT)
else:
check posix_madvise(newCommitEnd, commitSizeShrinkage,
POSIX_MADV_DONTNEED) == 0
m.committedMemEnd = newCommitEnd
upon further investigation i found this comment:
OpenBSD however doesn't implement posix_madvise().
but there's some contradiction with other sources I found on the topic; it my depend on glibc etc
looks like it's in fact check mprotect
the culprit (really hard to debug via CI)
check mprotect(m.committedMemEnd, commitExtensionSize,
m.accessFlags.cint) == 0
I can't find any relevant reference on the web / nim sources to "Not supported" from the errmsg
Error: unhandled exception: Not supported [OSError]
so it's not clear where that comes from.
Further investigation needs to look what was this equal to: m.accessFlags.cint
There are several
nimhcr
tests that fail on OpenBSD with aNot supported [OSError]
error. THe problem appears to be in thereservedmem
module as they all fail with a stacktrace similar to the following: