Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example code crashes on linux #12

Open
2 tasks done
Trzyipolkostkicukru opened this issue Jun 4, 2021 · 1 comment
Open
2 tasks done

Example code crashes on linux #12

Trzyipolkostkicukru opened this issue Jun 4, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@Trzyipolkostkicukru
Copy link

Example code from README.md crashes on linux. The message I'm getting after installing swift-backtrace is
"Swift runtime failure: Double value cannot be converted to Int because it is either infinite or NaN"

Project files without the ".build" directory ThisIsBenchmark.zip (if I included .build it would be too big for github)

Information

  • Package version: main branch
  • Platform version: Ubuntu 20.04.2 LTS running in a VM
  • Swift version: Swift version 5.5-dev (LLVM 8c37fc45eae308f, Swift 63b62320eb022d8) Target: x86_64-unknown-linux-gnu

Checklist

  • If possible, I've reproduced the issue using the main branch of this package.
  • I've searched for existing GitHub issues.

Steps to Reproduce

Replace this paragraph with an explanation of how to reproduce the incorrect behavior.
Include a simple code example, if possible.

  • create new executable package
  • add swift-collections-benchmark dependency
  • copy-paste example benchmarks from README.md to main.swift
  • optionally add swift-backtrace to show more info on crash
  • run swift run -c release ThisIsBenchmark run out in terminal

Expected behavior

package is compiled, and example benchmark is executed

Actual behavior

package is compiled with a "remark: Incremental compilation has been disabled: it is not compatible with whole module optimization", but crashes at runtime. Without the backtrace package the error doesn't say anything, but with the backtrace package it looks like this:

Running 2 tasks on 76 sizes from 1 to 1M:
  Array<Int> sorted
  Set<Int> contains
Output file: /home/cukier/Desktop/ThisIsBenchmark/out
Appending to existing data (if any) for these tasks/sizes.

Collecting data:
  10x7f3f4a3653bf
0x55b70ba8f75d, Swift runtime failure: Double value cannot be converted to Int because it is either infinite or NaN at /home/cukier/Desktop/ThisIsBenchmark/.build/checkouts/swift-collections-benchmark/Sources/CollectionsBenchmark/Benchmark/Task.swift:0
0x55b70ba8f75d, CollectionsBenchmark.Task.measure(size: CollectionsBenchmark.Size, input: A, options: CollectionsBenchmark.Benchmark.Options) -> Swift.Optional<CollectionsBenchmark.Time> at /home/cukier/Desktop/ThisIsBenchmark/.build/checkouts/swift-collections-benchmark/Sources/CollectionsBenchmark/Benchmark/Task.swift:121
0x55b70ba60956, CollectionsBenchmark._ConcreteTask.measure(size: CollectionsBenchmark.Size, input: Any, options: CollectionsBenchmark.Benchmark.Options) -> Swift.Optional<CollectionsBenchmark.Time> at /home/cukier/Desktop/ThisIsBenchmark/.build/checkouts/swift-collections-benchmark/Sources/CollectionsBenchmark/Benchmark/AnyTask.swift:119
0x55b70ba78101, CollectionsBenchmark.AnyTask.measure(size: CollectionsBenchmark.Size, input: Any, options: CollectionsBenchmark.Benchmark.Options) -> Swift.Optional<CollectionsBenchmark.Time> at .build/checkouts/swift-collections-benchmark/Sources/CollectionsBenchmark/Benchmark/AnyTask.swift:49
0x55b70ba78101, function signature specialization <Arg[3] = [Closure Propagated : closure #2 (CollectionsBenchmark.Benchmark.Event) throws -> () in CollectionsBenchmark._Document.run(benchmark: CollectionsBenchmark.Benchmark, options: CollectionsBenchmark.Benchmark.Options) throws -> (), Argument Types : [Swift.BoolCollectionsBenchmark._Document]> of CollectionsBenchmark.Benchmark.measureOneCycle(tasks: Swift.Array<CollectionsBenchmark.AnyTask>, sizes: Swift.Array<CollectionsBenchmark.Size>, options: CollectionsBenchmark.Benchmark.Options, delegate: (CollectionsBenchmark.Benchmark.Event) throws -> ()) throws -> () at /home/cukier/Desktop/ThisIsBenchmark/.build/checkouts/swift-collections-benchmark/Sources/CollectionsBenchmark/Benchmark/Benchmark+RunOptions.swift:40
0x55b70ba7963d, function signature specialization <Arg[1] = [Closure Propagated : closure #2 (CollectionsBenchmark.Benchmark.Event) throws -> () in CollectionsBenchmark._Document.run(benchmark: CollectionsBenchmark.Benchmark, options: CollectionsBenchmark.Benchmark.Options) throws -> (), Argument Types : [Swift.BoolCollectionsBenchmark._Document]> of CollectionsBenchmark.Benchmark.run(options: CollectionsBenchmark.Benchmark.Options, delegate: (CollectionsBenchmark.Benchmark.Event) throws -> ()) throws -> () at /home/cukier/Desktop/ThisIsBenchmark/.build/checkouts/swift-collections-benchmark/Sources/CollectionsBenchmark/Benchmark/Benchmark+RunOptions.swift:73
0x55b70bae0a41, CollectionsBenchmark._Document.run(benchmark: CollectionsBenchmark.Benchmark, options: CollectionsBenchmark.Benchmark.Options) throws -> () at /home/cukier/Desktop/ThisIsBenchmark/.build/checkouts/swift-collections-benchmark/Sources/CollectionsBenchmark/BenchmarkCLI/_Document.swift:149
0x55b70badb00b, CollectionsBenchmark._BenchmarkCLI.Run.run(benchmark: CollectionsBenchmark.Benchmark) throws -> () at /home/cukier/Desktop/ThisIsBenchmark/.build/checkouts/swift-collections-benchmark/Sources/CollectionsBenchmark/BenchmarkCLI/BenchmarkCLI+Run.swift:76
0x55b70badb23f, protocol witness for CollectionsBenchmark._BenchmarkCommand.run(benchmark: CollectionsBenchmark.Benchmark) throws -> () in conformance CollectionsBenchmark._BenchmarkCLI.Run : CollectionsBenchmark._BenchmarkCommand in CollectionsBenchmark at /home/cukier/Desktop/ThisIsBenchmark/<compiler-generated>:0
0x55b70ba6a9fc, CollectionsBenchmark.Benchmark.main() -> () at /home/cukier/Desktop/ThisIsBenchmark/.build/checkouts/swift-collections-benchmark/Sources/CollectionsBenchmark/Benchmark/Benchmark+Main.swift:32
0x55b70bb316f2, ThisIsBenchmark_main at /home/cukier/Desktop/ThisIsBenchmark/Sources/ThisIsBenchmark/main.swift:27
0x7f3f498d60b2
0x55b70b9da6dd
0xffffffffffffffff
Illegal instruction (core dumped)
@lorentey
Copy link
Member

lorentey commented Feb 3, 2024

Also reproduced on macOS: apple/swift-collections#345 (comment)

This can happen when the average duration measured happens to be zero. The fix ought to be straightforward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants