schveiguy / iopipe

D language library for modular io
Boost Software License 1.0
77 stars 6 forks source link

@safe build failure with v0.2.0 #31

Closed jondegenhardt closed 4 years ago

jondegenhardt commented 4 years ago

Hi Steve,

I ran my dcat-perf build and got a failure. Essentially, an iopipe @safe function trying to call an @system function.

I don't have time to debug this right now and figure out if it is something I need to change in my code or if it's a problem in iopipe. However, a quick look suggests it may be an @safe iopipe function invoking an @system iopipe funtion, or it could be related to the underlying input source my code provide (io.File). Haven't had time to figure this out yet.

The key error message:

iopipe-0.2.0/iopipe/source/iopipe/bufpipe.d(425,6): Error:

@safe function iopipe.bufpipe.arrayCastPipe!(char, BufferedInputSource!(AllocatedBuffer!(ubyte, GCNoPointerAllocator, 8192LU), RefCounted!(File, cast(RefCountedAutoInitialize)0), 8192LU)).arrayCastPipe

cannot call @system destructor iopipe.bufpipe.BufferedInputSource!(AllocatedBuffer!(ubyte, GCNoPointerAllocator, 8192LU), RefCounted!(File, cast(RefCountedAutoInitialize)0), 8192LU).BufferedInputSource.~this

The function where it occurs is at: dcat-perf app.d line 294. The line where the failure occurs:

foreach (ref line; inputStream.bufd.assumeText.byLineRange)

where inputStream is an open file created by io.File.

The build log

$ $DC --version
DMD64 D Compiler v2.090.1
Copyright (C) 1999-2019 by The D Language Foundation, All Rights Reserved written by Walter Bright
$ dub --help | tail -n 1
DUB version 1.19.0, built on Feb  9 2020
0.00s$ if [[ "$LTO_PGO" == "1" ]]; then dub build --compiler=ldc2 --build=release-lto-pgo --build-mode=allAtOnce --combined && dub build --build=cli-test --combined; fi
The command "if [[ "$LTO_PGO" == "1" ]]; then dub build --compiler=ldc2 --build=release-lto-pgo --build-mode=allAtOnce --combined && dub build --build=cli-test --combined; fi" exited with 0.
0.00s$ if [[ "$LTO" == "1" ]]; then dub build --compiler=ldc2 --build=release-lto --build-mode=allAtOnce --combined && dub build --build=cli-test --combined; fi
The command "if [[ "$LTO" == "1" ]]; then dub build --compiler=ldc2 --build=release-lto --build-mode=allAtOnce --combined && dub build --build=cli-test --combined; fi" exited with 0.
5.68s$ if [[ "$CLI_TEST" == "1" ]]; then dub build --build=cli-test --combined; fi
Fetching iopipe 0.2.0 (getting selected version)...
Fetching io 0.2.5 (getting selected version)...
Fetching tsv-utils 1.6.1 (getting selected version)...
Performing "cli-test" build using /home/travis/dlang/dmd-2.090.1/linux/bin64/dmd for x86_64.
dcat-perf ~master: building configuration "default"...
../../../.dub/packages/iopipe-0.2.0/iopipe/source/iopipe/bufpipe.d(425,6): Error: @safe function iopipe.bufpipe.arrayCastPipe!(char, BufferedInputSource!(AllocatedBuffer!(ubyte, GCNoPointerAllocator, 8192LU), RefCounted!(File, cast(RefCountedAutoInitialize)0), 8192LU)).arrayCastPipe cannot call @system destructor iopipe.bufpipe.BufferedInputSource!(AllocatedBuffer!(ubyte, GCNoPointerAllocator, 8192LU), RefCounted!(File, cast(RefCountedAutoInitialize)0), 8192LU).BufferedInputSource.~this
../../../.dub/packages/iopipe-0.2.0/iopipe/source/iopipe/bufpipe.d(499,1):        iopipe.bufpipe.BufferedInputSource!(AllocatedBuffer!(ubyte, GCNoPointerAllocator, 8192LU), RefCounted!(File, cast(RefCountedAutoInitialize)0), 8192LU).BufferedInputSource.~this is declared here
../../../.dub/packages/iopipe-0.2.0/iopipe/source/iopipe/bufpipe.d(430,41): Error: @safe function iopipe.bufpipe.arrayCastPipe!(char, BufferedInputSource!(AllocatedBuffer!(ubyte, GCNoPointerAllocator, 8192LU), RefCounted!(File, cast(RefCountedAutoInitialize)0), 8192LU)).arrayCastPipe cannot call @system generated function iopipe.bufpipe.BufferedInputSource!(AllocatedBuffer!(ubyte, GCNoPointerAllocator, 8192LU), RefCounted!(File, cast(RefCountedAutoInitialize)0), 8192LU).BufferedInputSource.__fieldPostblit
../../../.dub/packages/iopipe-0.2.0/iopipe/source/iopipe/bufpipe.d(499,1):        iopipe.bufpipe.BufferedInputSource!(AllocatedBuffer!(ubyte, GCNoPointerAllocator, 8192LU), RefCounted!(File, cast(RefCountedAutoInitialize)0), 8192LU).BufferedInputSource.__fieldPostblit is declared here
../../../.dub/packages/iopipe-0.2.0/iopipe/source/iopipe/textpipe.d(251,17): Error: template instance iopipe.bufpipe.arrayCastPipe!(char, BufferedInputSource!(AllocatedBuffer!(ubyte, GCNoPointerAllocator, 8192LU), RefCounted!(File, cast(RefCountedAutoInitialize)0), 8192LU)) error instantiating
source/app.d(320,40):        instantiated from here: assumeText!(cast(UTFType)1, BufferedInputSource!(AllocatedBuffer!(ubyte, GCNoPointerAllocator, 8192LU), RefCounted!(File, cast(RefCountedAutoInitialize)0), 8192LU))
source/app.d(201,32):        instantiated from here: useIopipeByLineInBufOut!(BufferedOutputRange!(File))
/home/travis/dlang/dmd-2.090.1/linux/bin64/dmd failed with exit code 1.
jondegenhardt commented 4 years ago

Update: Looks like I'm using io.File, not std.stdio.File like I originally stated. Apologies for that. It's a little confusing in my code where File is coming from, and sometimes it comes from Phobos, sometimes from io.

I've corrected it in the original message.

Also, I'm not wrapping it in RefCounted, as shown in at least some of the iopipe examples. That may be the underlying issue. I'll try changing this later.

schveiguy commented 4 years ago

OK, thanks. One of the problems of adding @safe support to a library is you have to temporarily mark things @safe to see why it's inferred system. I probably forgot to remove one.

schveiguy commented 4 years ago

updated, try 0.2.1.

jondegenhardt commented 4 years ago

That fixed it, all my CI suite passes now. Thanks!