diff --git a/Dockerfile b/Dockerfile index 3d37dd6..f06ee8f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ WORKDIR /code # Removes any already existing binary so that when compilation fails the container stops RUN rm -f /code/nimd -RUN nim -d:release --opt:size --passL:"-static" c -o:nimd src/main +RUN nim -d:release --opt:size --passL:"-static" --gc:orc -d:useMalloc c -o:nimd src/main RUN cp /code/nimd /sbin/nimd FROM alpine:latest diff --git a/src/util/disks.nim b/src/util/disks.nim index 1ef8151..2958f52 100644 --- a/src/util/disks.nim +++ b/src/util/disks.nim @@ -58,6 +58,9 @@ proc parseFileSystemTable*(fstab: string): seq[tuple[source, target, filesystemt # Nim wrappers around C functionality in sys/mount.h on Linux proc mount*(source: cstring, target: cstring, filesystemtype: cstring, mountflags: culong, data: pointer): cint {.header: "sys/mount.h", importc.} +# Since cstrings are weak references, we need to convert nim strings to cstrings only +# when we're ready to use them and only when we're sure the underlying nim string is +# in scope, otherwise garbage collection madness happens proc mount*(source, target, filesystemtype: string, mountflags: uint64, data: string): int = int(mount(cstring(source), cstring(target), cstring(filesystemtype), culong(mountflags), cstring(data))) proc umount*(target: cstring): cint {.header: "sys/mount.h", importc.}