Skip to content

Swift fatal error on Ubuntu 16.04 (also command line arguments parsing issues) #4

@tlongeri

Description

@tlongeri

Hi, I built pcb2photon on Ubuntu 16.04 as follows:

$ git clone https://github.com/Reonarudo/pcb2photon.git pcb2photon
Cloning into 'pcb2photon'...
remote: Counting objects: 433, done.
remote: Compressing objects: 100% (54/54), done.
remote: Total 433 (delta 50), reused 73 (delta 28), pack-reused 331
Receiving objects: 100% (433/433), 15.72 MiB | 2.15 MiB/s, done.
Resolving deltas: 100% (193/193), done.
Checking connectivity... done.
$ cd pcb2photon
$ swift build
Fetching https://github.com/SwiftGL/Image.git
Cloning https://github.com/SwiftGL/Image.git
Resolving https://github.com/SwiftGL/Image.git at 2.2.0
Compile Swift Module 'SGLImage' (6 sources)
/home/tomas/installations/test/pcb2photon/.build/checkouts/Image.git-8898945789819335455/Sources/SGLImage/Image.swift:119:29: warning: 'deallocate(capacity:)' is deprecated: Swift currently only supports freeing entire heap blocks, use deallocate() instead
        buffer.baseAddress!.deallocate(capacity: buffer.count)
                            ^
Compile Swift Module 'pcb2photon' (6 sources)
Linking ./.build/x86_64-unknown-linux/debug/pcb2photon
$ cp test.png .build/debug
$ cd .build/debug
$ ./pcb2photon test.png
$

When running pcb2photon at first I got no responsiveness at all (terminated instantly with no shell output and no files being generated), but soon I realized some error messages do work

$ ./pcb2photon test.png -t
Error: 01 Invalid value for t.
$

I have zero experience with swift, but after looking at the code I changed the following (lines 147-152 of Converter.swift):

                    var newFileNames : [String] = []
                    i+=1
                    while i < min(filesToConvert.count, Int(argCount)){
                        newFileNames.append(CommandLine.arguments[i])
                        i+=1
                    }

into

                    self.conversionOptions.output = []
                    i+=1
                    let i0 = i
                    while i < min(i0 + filesToConvert.count, Int(argCount)){
                        self.conversionOptions.output.append(CommandLine.arguments[i])
                        i+=1
                    }

Now, this didn't fix the non-responsiveness if I didn't specify an output file, or if I didn't specify anything at all, but at least I could get past the parsing of the arguments now.

After building with that change, I tried again:

$ ./pcb2photon test.png -o test.out
Fatal error: 'try!' expression unexpectedly raised an error: The operation could not be completed: file /home/buildnode/jenkins/workspace/oss-swift-4.1-package-linux-ubuntu-16_04/swift/stdlib/public/core/ErrorType.swift, line 184
Current stack trace:
0    libswiftCore.so                    0x00007f2bada2c680 _swift_stdlib_reportFatalErrorInFile + 221
1    libswiftCore.so                    0x00007f2bad79b38c <unavailable> + 1368972
2    libswiftCore.so                    0x00007f2bad9d52f2 <unavailable> + 3703538
3    libswiftCore.so                    0x00007f2bad9d6759 <unavailable> + 3708761
4    libswiftCore.so                    0x00007f2bad79aa86 <unavailable> + 1366662
5    libswiftCore.so                    0x00007f2bad9d50bb <unavailable> + 3702971
6    libswiftCore.so                    0x00007f2bad79aa86 <unavailable> + 1366662
7    libswiftCore.so                    0x00007f2bad9080b9 <unavailable> + 2863289
8    libswiftCore.so                    0x00007f2bad7d8840 swift_unexpectedError + 318
Illegal instruction (core dumped)
$

This time it took a while before crashing, so it looked like it was actually doing something. I omitted logging messages I added into the code, but I'm quite sure that the arguments were parsed correctly and it crashed deeper in the program.

That's as far as I got. I'm not sure what is causing this error, so I would really appreciate it if you help out. This seems like a great tool that could easily save someone like me several hours of work (who just discovered the most available means of getting some quick PCBs has turned out to be printing them in our DLP printer).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions